Browse Source

图表详情折线图数据处理

develop
fuguobin 1 year ago
parent
commit
54c4bdc8ac
  1. 40
      src/api/device/index.ts
  2. 33
      src/api/device/types.ts
  3. 4
      src/types/auto-imports.d.ts
  4. 202
      src/views/details/index - 副本 (2).vue
  5. 187
      src/views/details/index - 副本.vue
  6. 7
      src/views/details/index.scss
  7. 781
      src/views/details/index.vue
  8. 144
      src/views/monitoring/screen/components/main.vue
  9. 6
      vite.config.ts

40
src/api/device/index.ts

@ -58,3 +58,43 @@ export function editConfig(data: any) {
data: data data: data
}); });
} }
/**
*
*/
export function getDevices(): AxiosPromise<[]> {
return request({
url: '/dc/dcDeviceEcharts/getDevices',
method: 'get'
});
}
/**
*
*/
export function getParams(): AxiosPromise<[]> {
return request({
url: '/dc/dcDeviceEcharts/getParams',
method: 'get'
});
}
/**
*
*/
export function getPortions(): AxiosPromise<[]> {
return request({
url: '/dc/dcDeviceEcharts/getPortions',
method: 'get'
});
}
/**
* 线
*
* @param data
*/
export function getDeviceInfos(data: any) {
return request({
url: '/dc/dcDeviceEcharts/getDeviceInfos',
method: 'post',
data: data
});
}

33
src/api/device/types.ts

@ -40,3 +40,36 @@ export interface headerVo {
ctrlFlag: string; ctrlFlag: string;
paramUnit: string; paramUnit: string;
} }
export interface deetsVo {
centerDeviceCode: string;
deviceName: string;
}
export interface partitionVo {
createBy: string;
createTime: string;
cssClass: null;
default: boolean;
dictCode: number;
dictLabel: string;
dictSort: number;
dictType: string;
dictValue: string;
isDefault: null;
listClass: string;
remark: null;
status: string;
updateBy: null;
updateTime: null;
}
export interface parameterVo {
classType: string;
createTime: null;
deleteTime: null;
id: number;
note: null;
paramClassCode: string;
paramClassName: string;
paramUnit: string;
updateTime: null;
version: null;
}

4
src/types/auto-imports.d.ts

@ -5,8 +5,6 @@ declare global {
const ElForm: typeof import('element-plus/es')['ElForm'] const ElForm: typeof import('element-plus/es')['ElForm']
const ElMessage: typeof import('element-plus/es')['ElMessage'] const ElMessage: typeof import('element-plus/es')['ElMessage']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const ElNotification: typeof import('element-plus/es')['ElNotification']
const NEllipsis: typeof import('naive-ui')['NEllipsis']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed'] const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef'] const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
const computed: typeof import('vue')['computed'] const computed: typeof import('vue')['computed']
@ -276,8 +274,6 @@ declare module 'vue' {
readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']> readonly ElForm: UnwrapRef<typeof import('element-plus/es')['ElForm']>
readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']> readonly ElMessage: UnwrapRef<typeof import('element-plus/es')['ElMessage']>
readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']> readonly ElMessageBox: UnwrapRef<typeof import('element-plus/es')['ElMessageBox']>
readonly ElNotification: UnwrapRef<typeof import('element-plus/es')['ElNotification']>
readonly NEllipsis: UnwrapRef<typeof import('naive-ui')['NEllipsis']>
readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']> readonly asyncComputed: UnwrapRef<typeof import('@vueuse/core')['asyncComputed']>
readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']> readonly autoResetRef: UnwrapRef<typeof import('@vueuse/core')['autoResetRef']>
readonly computed: UnwrapRef<typeof import('vue')['computed']> readonly computed: UnwrapRef<typeof import('vue')['computed']>

202
src/views/details/index - 副本 (2).vue

@ -0,0 +1,202 @@
<template>
<div class="details">
<el-card class="search" shadow="always">
<el-form ref="searchRef" :inline="true" :model="searchForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="时间" prop="time">
<el-date-picker
v-model="searchForm.time"
type="datetimerange"
start-placeholder="开始时间"
end-placeholder="结束时间"
:default-time="defaultTime1"
/>
</el-form-item>
<el-form-item label="颗粒度" prop="particle">
<el-select v-model="searchForm.particle" placeholder="请选择">
<el-option v-for="item in particleData" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="设备" prop="device">
<el-select v-model="searchForm.device" placeholder="请选择">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="参数" prop="parameter">
<el-select v-model="searchForm.parameter" placeholder="请选择">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm(searchRef)">确认</el-button>
<el-button @click="resetForm(searchRef)">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="echart" shadow="always">
<div class="comparisonInfo">
<div ref="stackedRef" class="stackedLine" />
</div>
</el-card>
</div>
</template>
<script lang="ts" setup>
import * as echarts from 'echarts';
import { Ref } from 'vue';
const stackedRef: Ref<HTMLElement | any> = ref(null);
import type { FormInstance } from 'element-plus';
const searchRef = ref<FormInstance>();
const defaultTime1 = new Date(2000, 1, 1, 12, 0, 0); // '12:00:00'
const searchForm = reactive({
time: '',
particle: '',
device: '',
parameter: ''
});
const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(valid => {
if (valid) {
console.log('submit!');
} else {
console.log('error submit!');
return false;
}
});
};
const resetForm = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.resetFields();
};
const particleData = [
{ label: '分钟', value: 1 },
{ label: '小时', value: 2 }
];
const optionss = [
{
value: 'Option1',
label: 'Option1'
},
{
value: 'Option2',
label: 'Option2'
}
];
const colors = ['#EE6666', '#91CC75', '#5470C6'];
const options = {
color: colors,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
}
},
grid: {
right: '20%'
},
toolbox: {
feature: {
dataView: { show: true, readOnly: false },
restore: { show: true },
saveAsImage: { show: true }
}
},
legend: {
data: ['回温', '供压', '回压']
},
xAxis: [
{
type: 'category',
axisTick: {
alignWithLabel: true
},
// prettier-ignore
data: ['2021', '2022', '2023', '2024', '2025', '2026', '2027', '2028', '2029', '2030', '2031', '2032']
}
],
yAxis: [
{
type: 'value',
name: '回温',
position: 'right',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: colors[0]
}
},
axisLabel: {
formatter: '{value} ml'
}
},
{
type: 'value',
name: '供压',
position: 'right',
alignTicks: true,
offset: 80,
axisLine: {
show: true,
lineStyle: {
color: colors[1]
}
},
axisLabel: {
formatter: '{value} ml'
}
},
{
type: 'value',
name: '回压',
position: 'left',
alignTicks: true,
axisLine: {
show: true,
lineStyle: {
color: colors[2]
}
},
axisLabel: {
formatter: '{value} °C'
}
}
],
series: [
{
name: '回温',
type: 'line',
data: [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
},
{
name: '供压',
type: 'line',
yAxisIndex: 2,
data: [5.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
},
{
name: '回压',
type: 'line',
yAxisIndex: 1,
data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
}
]
};
onMounted(() => {
//
const chart = echarts.init(stackedRef.value);
chart.setOption(options);
//
window.addEventListener('resize', () => {
chart.resize();
});
});
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>

187
src/views/details/index - 副本.vue

@ -0,0 +1,187 @@
<template>
<div class="details">
<el-card class="search" shadow="always">
<el-form ref="searchRef" :inline="true" :model="searchForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="时间" prop="time">
<el-date-picker
v-model="searchForm.time"
type="datetimerange"
start-placeholder="开始时间"
end-placeholder="结束时间"
:default-time="defaultTime1"
/>
</el-form-item>
<!-- <el-form-item label="颗粒度" prop="particle">
<el-select v-model="searchForm.particle" placeholder="请选择">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item> -->
<el-form-item label="设备" prop="device">
<el-select v-model="searchForm.device" placeholder="请选择">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="参数" prop="parameter">
<el-select v-model="searchForm.parameter" placeholder="请选择">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm(searchRef)">确认</el-button>
<el-button @click="resetForm(searchRef)">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="echart" shadow="always">
<div class="comparisonInfo">
<div ref="stackedRef" class="stackedLine" />
</div>
</el-card>
</div>
</template>
<script lang="ts" setup>
import * as echarts from 'echarts';
import { Ref } from 'vue';
const stackedRef: Ref<HTMLElement | any> = ref(null);
import type { FormInstance } from 'element-plus';
const searchRef = ref<FormInstance>();
const defaultTime1 = new Date(2000, 1, 1, 12, 0, 0); // '12:00:00'
const searchForm = reactive({
time: '',
particle: '',
device: '',
parameter: ''
});
const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(valid => {
if (valid) {
console.log('submit!');
} else {
console.log('error submit!');
return false;
}
});
};
const resetForm = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.resetFields();
};
const optionss = [
{
value: 'Option1',
label: 'Option1'
},
{
value: 'Option2',
label: 'Option2'
},
{
value: 'Option3',
label: 'Option3'
},
{
value: 'Option4',
label: 'Option4'
},
{
value: 'Option5',
label: 'Option5'
}
];
const options = {
title: {
text: 'Temperature Change in the Coming Week'
},
tooltip: {
trigger: 'axis'
},
legend: {},
toolbox: {
show: true,
feature: {
dataZoom: {
yAxisIndex: 'none'
},
dataView: { readOnly: false },
magicType: { type: ['line', 'bar'] },
restore: {},
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} °C'
}
},
series: [
{
name: 'Highest',
type: 'line',
data: [10, 11, 13, 11, 12, 12, 9],
markPoint: {
data: [
{ type: 'max', name: 'Max' },
{ type: 'min', name: 'Min' }
]
},
markLine: {
data: [{ type: 'average', name: 'Avg' }]
}
},
{
name: 'Lowest',
type: 'line',
data: [1, -2, 2, 5, 3, 2, 0],
markPoint: {
data: [{ name: '周最低', value: -2, xAxis: 1, yAxis: -1.5 }]
},
markLine: {
data: [
{ type: 'average', name: 'Avg' },
[
{
symbol: 'none',
x: '90%',
yAxis: 'max'
},
{
symbol: 'circle',
label: {
position: 'start',
formatter: 'Max'
},
type: 'max',
name: '最高点'
}
]
]
}
}
]
};
onMounted(() => {
//
const chart = echarts.init(stackedRef.value);
chart.setOption(options);
//
window.addEventListener('resize', () => {
chart.resize();
});
});
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>

7
src/views/details/index.scss

@ -2,12 +2,17 @@
padding: 1.5rem; padding: 1.5rem;
.search { .search {
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
.searchForm {
.item {
margin-bottom: 0;
}
}
} }
.echart { .echart {
.comparisonInfo { .comparisonInfo {
.stackedLine { .stackedLine {
width: 100%; width: 100%;
height: 500px; height: 80vh;
} }
} }
} }

781
src/views/details/index.vue

@ -1,29 +1,54 @@
<template> <template>
<div class="details"> <div class="details">
<el-card class="search" shadow="always"> <el-card class="search" shadow="always">
<el-form ref="searchRef" :inline="true" :model="searchForm" label-width="100px" class="demo-ruleForm"> <el-form class="searchForm" ref="searchRef" :inline="true" :model="searchForm" label-width="100px">
<el-form-item label="时间" prop="time"> <el-form-item class="item" label="时间" prop="time">
<el-date-picker <el-date-picker
v-model="searchForm.time" v-model="searchForm.time"
type="datetimerange" type="datetimerange"
start-placeholder="开始时间" start-placeholder="开始时间"
end-placeholder="结束时间" end-placeholder="结束时间"
:default-time="defaultTime1" format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
:default-time="defaultTime"
@change="timeChange"
/> />
</el-form-item> </el-form-item>
<el-form-item label="颗粒度" prop="particle"> <el-form-item class="item" label="设备" prop="device">
<el-select v-model="searchForm.particle" placeholder="请选择"> <el-select v-model="searchForm.device" multiple filterable placeholder="请选择设备" @change="deviceChange">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" /> <el-option
v-for="item in deviceData"
:key="item.centerDeviceCode"
:label="item.deviceName"
:value="item.centerDeviceCode"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="设备" prop="device"> <el-form-item class="item" label="参数" prop="parameter">
<el-select v-model="searchForm.device" placeholder="请选择"> <el-select
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" /> v-model="searchForm.parameter"
multiple
:multiple-limit="multipleLimit"
filterable
placeholder="请选择参数"
@change="parameterChange"
>
<el-option
v-for="item in parameterData"
:key="item.paramClassCode"
:label="item.paramClassName"
:value="item.paramClassCode"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="参数" prop="parameter"> <el-form-item class="item" label="分区" prop="partition">
<el-select v-model="searchForm.parameter" placeholder="请选择"> <el-select v-model="searchForm.partition" filterable placeholder="请选择分区" @change="partitionChange">
<el-option v-for="item in optionss" :key="item.value" :label="item.label" :value="item.value" /> <el-option
v-for="item in partitionData"
:key="item.dictValue"
:label="item.dictLabel"
:value="item.dictValue"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@ -45,142 +70,712 @@ import { Ref } from 'vue';
const stackedRef: Ref<HTMLElement | any> = ref(null); const stackedRef: Ref<HTMLElement | any> = ref(null);
import type { FormInstance } from 'element-plus'; import type { FormInstance } from 'element-plus';
import { getDevices, getParams, getPortions, getDeviceInfos } from '@/api/device/index';
import { deetsVo, partitionVo, parameterVo } from '@/api/device/types';
const searchRef = ref<FormInstance>(); const searchRef = ref<FormInstance>();
const defaultTime1 = new Date(2000, 1, 1, 12, 0, 0); // '12:00:00' const defaultTime = new Date(2000, 1, 1, 12, 0, 0); // '12:00:00'
const multipleLimit = ref(0);
const searchForm = reactive({ const searchForm = reactive({
time: '', time: '',
particle: '', device: [],
device: '', parameter: [],
parameter: '' partition: ''
}); });
const filterForm = reactive({
const submitForm = (formEl: FormInstance | undefined) => { startTime: '',
if (!formEl) return; endTime: '',
formEl.validate(valid => { deviceUuid: '',
if (valid) { paramCode: '',
console.log('submit!'); partion: ''
} else {
console.log('error submit!');
return false;
}
}); });
}; const colors = ['#5470c6', '#91cc75', '#fac858', '#1a94bc', '#f26b1f', '#5bae23'];
const deviceData = ref<deetsVo[]>();
const parameterData = ref<parameterVo[]>();
const partitionData = ref<partitionVo[]>();
const resetForm = (formEl: FormInstance | undefined) => { // let base = +new Date();
if (!formEl) return; // let oneDay = 24 * 3600 * 1000;
formEl.resetFields(); // let data = [[base, Math.random() * 300]];
}; // for (let i = 1; i < 200; i++) {
const optionss = [ // let now = new Date((base += oneDay));
{ // console.log('now--', now);
value: 'Option1', // data.push([+now, Math.round((Math.random() - 0.5) * 20 + data[i - 1][1])]);
label: 'Option1' // }
const options1 = {
title: {
text: '多设备单参数'
},
tooltip: {
trigger: 'axis'
// position: function (pt: any) {
// return [pt[0], '10%'];
// }
},
legend: {
data: ['华尔街3号站', '颐和城', '李相', '汪家新村', '白沙岛']
},
grid: {
top: '80',
left: '100',
right: '150',
bottom: '50',
containLabel: true
},
toolbox: {
feature: {
restore: {}
}
},
xAxis: {
type: 'time',
boundaryGap: false
},
yAxis: {
type: 'value',
scale: true, //
minInterval: 1, //
name: '单位()',
nameTextStyle: {
color: '#000',
fontSize: 12,
padding: [0, 0, 0, 0] //name
},
axisTick: {
//
show: false
}
// boundaryGap: [0, '100%']
}, },
dataZoom: [
{ {
value: 'Option2', type: 'inside',
label: 'Option2' startValue: '0'
// start: 0,
// end: 20
}, },
{ {
value: 'Option3', startValue: '0'
label: 'Option3' // start: 0,
// end: 20
}
],
series: [
{
name: '华尔街3号站',
type: 'line',
smooth: true,
symbol: 'none',
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 500)],
['2023-10-01 09:00:00', Math.round(Math.random() * 500)],
['2023-10-01 10:00:00', Math.round(Math.random() * 500)],
['2023-10-01 11:00:00', Math.round(Math.random() * 500)],
['2023-10-01 12:00:00', Math.round(Math.random() * 500)],
['2023-10-01 13:00:00', Math.round(Math.random() * 500)],
['2023-10-01 14:00:00', Math.round(Math.random() * 500)],
['2023-10-01 15:00:00', Math.round(Math.random() * 500)],
['2023-10-02 08:00:00', Math.round(Math.random() * 500)],
['2023-10-02 09:00:00', Math.round(Math.random() * 500)],
['2023-10-02 10:00:00', Math.round(Math.random() * 500)],
['2023-10-02 11:00:00', Math.round(Math.random() * 500)],
['2023-10-02 12:00:00', Math.round(Math.random() * 500)],
['2023-10-02 13:00:00', Math.round(Math.random() * 500)],
['2023-10-02 14:00:00', Math.round(Math.random() * 500)],
['2023-10-02 15:00:00', Math.round(Math.random() * 500)],
['2023-10-03 08:00:00', Math.round(Math.random() * 500)],
['2023-10-03 09:00:00', Math.round(Math.random() * 500)],
['2023-10-03 10:00:00', Math.round(Math.random() * 500)],
['2023-10-03 11:00:00', Math.round(Math.random() * 500)],
['2023-10-03 12:00:00', Math.round(Math.random() * 500)],
['2023-10-03 13:00:00', Math.round(Math.random() * 500)],
['2023-10-03 14:00:00', Math.round(Math.random() * 500)],
['2023-10-03 15:00:00', Math.round(Math.random() * 500)],
['2023-10-04 08:00:00', Math.round(Math.random() * 500)],
['2023-10-04 09:00:00', Math.round(Math.random() * 500)],
['2023-10-04 10:00:00', Math.round(Math.random() * 500)],
['2023-10-04 11:00:00', Math.round(Math.random() * 500)],
['2023-10-04 12:00:00', Math.round(Math.random() * 500)],
['2023-10-04 13:00:00', Math.round(Math.random() * 500)],
['2023-10-04 14:00:00', Math.round(Math.random() * 500)],
['2023-10-04 15:00:00', Math.round(Math.random() * 500)],
['2023-10-05 08:00:00', Math.round(Math.random() * 500)],
['2023-10-05 09:00:00', Math.round(Math.random() * 500)],
['2023-10-05 10:00:00', Math.round(Math.random() * 500)],
['2023-10-05 11:00:00', Math.round(Math.random() * 500)],
['2023-10-05 12:00:00', Math.round(Math.random() * 500)],
['2023-10-05 13:00:00', Math.round(Math.random() * 500)],
['2023-10-05 14:00:00', Math.round(Math.random() * 500)],
['2023-10-05 15:00:00', Math.round(Math.random() * 500)],
['2023-10-06 08:00:00', Math.round(Math.random() * 500)],
['2023-10-06 09:00:00', Math.round(Math.random() * 500)],
['2023-10-06 10:00:00', Math.round(Math.random() * 500)],
['2023-10-06 11:00:00', Math.round(Math.random() * 500)],
['2023-10-06 12:00:00', Math.round(Math.random() * 500)],
['2023-10-06 13:00:00', Math.round(Math.random() * 500)],
['2023-10-06 14:00:00', Math.round(Math.random() * 500)],
['2023-10-06 15:00:00', Math.round(Math.random() * 500)],
['2023-10-07 08:00:00', Math.round(Math.random() * 500)],
['2023-10-07 09:00:00', Math.round(Math.random() * 500)],
['2023-10-07 10:00:00', Math.round(Math.random() * 500)],
['2023-10-07 11:00:00', Math.round(Math.random() * 500)],
['2023-10-07 12:00:00', Math.round(Math.random() * 500)],
['2023-10-07 13:00:00', Math.round(Math.random() * 500)],
['2023-10-07 14:00:00', Math.round(Math.random() * 500)],
['2023-10-07 15:00:00', Math.round(Math.random() * 500)]
]
}, },
{ {
value: 'Option4', name: '颐和城',
label: 'Option4' type: 'line',
smooth: true,
symbol: 'none',
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 500)],
['2023-10-01 09:00:00', Math.round(Math.random() * 500)],
['2023-10-01 10:00:00', Math.round(Math.random() * 500)],
['2023-10-01 11:00:00', Math.round(Math.random() * 500)],
['2023-10-01 12:00:00', Math.round(Math.random() * 500)],
['2023-10-01 13:00:00', Math.round(Math.random() * 500)],
['2023-10-01 14:00:00', Math.round(Math.random() * 500)],
['2023-10-01 15:00:00', Math.round(Math.random() * 500)],
['2023-10-02 08:00:00', Math.round(Math.random() * 500)],
['2023-10-02 09:00:00', Math.round(Math.random() * 500)],
['2023-10-02 10:00:00', Math.round(Math.random() * 500)],
['2023-10-02 11:00:00', Math.round(Math.random() * 500)],
['2023-10-02 12:00:00', Math.round(Math.random() * 500)],
['2023-10-02 13:00:00', Math.round(Math.random() * 500)],
['2023-10-02 14:00:00', Math.round(Math.random() * 500)],
['2023-10-02 15:00:00', Math.round(Math.random() * 500)],
['2023-10-03 08:00:00', Math.round(Math.random() * 500)],
['2023-10-03 09:00:00', Math.round(Math.random() * 500)],
['2023-10-03 10:00:00', Math.round(Math.random() * 500)],
['2023-10-03 11:00:00', Math.round(Math.random() * 500)],
['2023-10-03 12:00:00', Math.round(Math.random() * 500)],
['2023-10-03 13:00:00', Math.round(Math.random() * 500)],
['2023-10-03 14:00:00', Math.round(Math.random() * 500)],
['2023-10-03 15:00:00', Math.round(Math.random() * 500)],
['2023-10-04 08:00:00', Math.round(Math.random() * 500)],
['2023-10-04 09:00:00', Math.round(Math.random() * 500)],
['2023-10-04 10:00:00', Math.round(Math.random() * 500)],
['2023-10-04 11:00:00', Math.round(Math.random() * 500)],
['2023-10-04 12:00:00', Math.round(Math.random() * 500)],
['2023-10-04 13:00:00', Math.round(Math.random() * 500)],
['2023-10-04 14:00:00', Math.round(Math.random() * 500)],
['2023-10-04 15:00:00', Math.round(Math.random() * 500)],
['2023-10-05 08:00:00', Math.round(Math.random() * 500)],
['2023-10-05 09:00:00', Math.round(Math.random() * 500)],
['2023-10-05 10:00:00', Math.round(Math.random() * 500)],
['2023-10-05 11:00:00', Math.round(Math.random() * 500)],
['2023-10-05 12:00:00', Math.round(Math.random() * 500)],
['2023-10-05 13:00:00', Math.round(Math.random() * 500)],
['2023-10-05 14:00:00', Math.round(Math.random() * 500)],
['2023-10-05 15:00:00', Math.round(Math.random() * 500)],
['2023-10-06 08:00:00', Math.round(Math.random() * 500)],
['2023-10-06 09:00:00', Math.round(Math.random() * 500)],
['2023-10-06 10:00:00', Math.round(Math.random() * 500)],
['2023-10-06 11:00:00', Math.round(Math.random() * 500)],
['2023-10-06 12:00:00', Math.round(Math.random() * 500)],
['2023-10-06 13:00:00', Math.round(Math.random() * 500)],
['2023-10-06 14:00:00', Math.round(Math.random() * 500)],
['2023-10-06 15:00:00', Math.round(Math.random() * 500)],
['2023-10-07 08:00:00', Math.round(Math.random() * 500)],
['2023-10-07 09:00:00', Math.round(Math.random() * 500)],
['2023-10-07 10:00:00', Math.round(Math.random() * 500)],
['2023-10-07 11:00:00', Math.round(Math.random() * 500)],
['2023-10-07 12:00:00', Math.round(Math.random() * 500)],
['2023-10-07 13:00:00', Math.round(Math.random() * 500)],
['2023-10-07 14:00:00', Math.round(Math.random() * 500)],
['2023-10-07 15:00:00', Math.round(Math.random() * 500)]
]
}, },
{ {
value: 'Option5', name: '李相',
label: 'Option5' type: 'line',
smooth: true,
symbol: 'none',
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 500)],
['2023-10-01 09:00:00', Math.round(Math.random() * 500)],
['2023-10-01 10:00:00', Math.round(Math.random() * 500)],
['2023-10-01 11:00:00', Math.round(Math.random() * 500)],
['2023-10-01 12:00:00', Math.round(Math.random() * 500)],
['2023-10-01 13:00:00', Math.round(Math.random() * 500)],
['2023-10-01 14:00:00', Math.round(Math.random() * 500)],
['2023-10-01 15:00:00', Math.round(Math.random() * 500)],
['2023-10-02 08:00:00', Math.round(Math.random() * 500)],
['2023-10-02 09:00:00', Math.round(Math.random() * 500)],
['2023-10-02 10:00:00', Math.round(Math.random() * 500)],
['2023-10-02 11:00:00', Math.round(Math.random() * 500)],
['2023-10-02 12:00:00', Math.round(Math.random() * 500)],
['2023-10-02 13:00:00', Math.round(Math.random() * 500)],
['2023-10-02 14:00:00', Math.round(Math.random() * 500)],
['2023-10-02 15:00:00', Math.round(Math.random() * 500)],
['2023-10-03 08:00:00', Math.round(Math.random() * 500)],
['2023-10-03 09:00:00', Math.round(Math.random() * 500)],
['2023-10-03 10:00:00', Math.round(Math.random() * 500)],
['2023-10-03 11:00:00', Math.round(Math.random() * 500)],
['2023-10-03 12:00:00', Math.round(Math.random() * 500)],
['2023-10-03 13:00:00', Math.round(Math.random() * 500)],
['2023-10-03 14:00:00', Math.round(Math.random() * 500)],
['2023-10-03 15:00:00', Math.round(Math.random() * 500)],
['2023-10-04 08:00:00', Math.round(Math.random() * 500)],
['2023-10-04 09:00:00', Math.round(Math.random() * 500)],
['2023-10-04 10:00:00', Math.round(Math.random() * 500)],
['2023-10-04 11:00:00', Math.round(Math.random() * 500)],
['2023-10-04 12:00:00', Math.round(Math.random() * 500)],
['2023-10-04 13:00:00', Math.round(Math.random() * 500)],
['2023-10-04 14:00:00', Math.round(Math.random() * 500)],
['2023-10-04 15:00:00', Math.round(Math.random() * 500)],
['2023-10-05 08:00:00', Math.round(Math.random() * 500)],
['2023-10-05 09:00:00', Math.round(Math.random() * 500)],
['2023-10-05 10:00:00', Math.round(Math.random() * 500)],
['2023-10-05 11:00:00', Math.round(Math.random() * 500)],
['2023-10-05 12:00:00', Math.round(Math.random() * 500)],
['2023-10-05 13:00:00', Math.round(Math.random() * 500)],
['2023-10-05 14:00:00', Math.round(Math.random() * 500)],
['2023-10-05 15:00:00', Math.round(Math.random() * 500)],
['2023-10-06 08:00:00', Math.round(Math.random() * 500)],
['2023-10-06 09:00:00', Math.round(Math.random() * 500)],
['2023-10-06 10:00:00', Math.round(Math.random() * 500)],
['2023-10-06 11:00:00', Math.round(Math.random() * 500)],
['2023-10-06 12:00:00', Math.round(Math.random() * 500)],
['2023-10-06 13:00:00', Math.round(Math.random() * 500)],
['2023-10-06 14:00:00', Math.round(Math.random() * 500)],
['2023-10-06 15:00:00', Math.round(Math.random() * 500)],
['2023-10-07 08:00:00', Math.round(Math.random() * 500)],
['2023-10-07 09:00:00', Math.round(Math.random() * 500)],
['2023-10-07 10:00:00', Math.round(Math.random() * 500)],
['2023-10-07 11:00:00', Math.round(Math.random() * 500)],
['2023-10-07 12:00:00', Math.round(Math.random() * 500)],
['2023-10-07 13:00:00', Math.round(Math.random() * 500)],
['2023-10-07 14:00:00', Math.round(Math.random() * 500)],
['2023-10-07 15:00:00', Math.round(Math.random() * 500)]
]
} }
]; ]
};
const options = { const options2 = {
color: colors,
title: { title: {
text: 'Temperature Change in the Coming Week' text: '单设备多参数'
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
// position: function (pt: any) {
// return [pt[0], '10%'];
// }
},
legend: {
data: ['瞬时流量', '瞬时热量', '累计热量']
},
grid: {
top: '80',
left: '100',
right: '150',
bottom: '50',
containLabel: true
}, },
legend: {},
toolbox: { toolbox: {
show: true,
feature: { feature: {
dataZoom: { restore: {}
yAxisIndex: 'none'
},
dataView: { readOnly: false },
magicType: { type: ['line', 'bar'] },
restore: {},
saveAsImage: {}
} }
}, },
xAxis: { xAxis: {
type: 'category', type: 'time',
boundaryGap: false, boundaryGap: false
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
}, },
yAxis: { yAxis: [
{
type: 'value', type: 'value',
axisLabel: { name: '瞬时流量(m³/h)',
formatter: '{value} °C' position: 'left',
alignTicks: true,
scale: true, //
minInterval: 1, //
nameTextStyle: {
fontSize: 12,
padding: [0, 0, 0, 0] //name
},
axisTick: {
//
show: false
},
axisLine: {
show: true,
lineStyle: {
color: colors[0]
}
} }
}, },
series: [
{ {
name: 'Highest', type: 'value',
type: 'line', name: '瞬时热量(JG/h)',
data: [10, 11, 13, 11, 12, 12, 9], position: 'right',
markPoint: { alignTicks: true,
data: [ scale: true, //
{ type: 'max', name: 'Max' }, minInterval: 1, //
{ type: 'min', name: 'Min' } nameTextStyle: {
] fontSize: 12,
padding: [0, 0, 0, 0] //name
},
axisTick: {
//
show: false
}, },
markLine: { axisLine: {
data: [{ type: 'average', name: 'Avg' }] show: true,
lineStyle: {
color: colors[1]
}
} }
}, },
{ {
name: 'Lowest', type: 'value',
type: 'line', name: '累计热量(JG)',
data: [1, -2, 2, 5, 3, 2, 0], position: 'right',
markPoint: { alignTicks: true,
data: [{ name: '周最低', value: -2, xAxis: 1, yAxis: -1.5 }] offset: 100,
scale: true, //
minInterval: 1, //
nameTextStyle: {
fontSize: 12,
padding: [0, 0, 0, 0] //name
}, },
markLine: { axisTick: {
data: [ //
{ type: 'average', name: 'Avg' }, show: false
[
{
symbol: 'none',
x: '90%',
yAxis: 'max'
}, },
axisLine: {
show: true,
lineStyle: {
color: colors[2]
}
}
}
],
// yAxis: {
// type: 'value',
// scale: true, //
// minInterval: 1, //
// name: '()',
// nameTextStyle: {
// color: '#000',
// fontSize: 12,
// padding: [0, 0, 0, 0] //name
// },
// axisTick: {
// //
// show: false
// }
// },
dataZoom: [
{ {
symbol: 'circle', type: 'inside',
label: { startValue: '0'
position: 'start', // start: 0,
formatter: 'Max' // end: 20
}, },
type: 'max', {
name: '最高点' startValue: '0'
// start: 0,
// end: 20
} }
],
series: [
{
name: '瞬时流量',
type: 'line',
smooth: true,
symbol: 'none',
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 500)],
['2023-10-01 09:00:00', Math.round(Math.random() * 500)],
['2023-10-01 10:00:00', Math.round(Math.random() * 500)],
['2023-10-01 11:00:00', Math.round(Math.random() * 500)],
['2023-10-01 12:00:00', Math.round(Math.random() * 500)],
['2023-10-01 13:00:00', Math.round(Math.random() * 500)],
['2023-10-01 14:00:00', Math.round(Math.random() * 500)],
['2023-10-01 15:00:00', Math.round(Math.random() * 500)],
['2023-10-02 08:00:00', Math.round(Math.random() * 500)],
['2023-10-02 09:00:00', Math.round(Math.random() * 500)],
['2023-10-02 10:00:00', Math.round(Math.random() * 500)],
['2023-10-02 11:00:00', Math.round(Math.random() * 500)],
['2023-10-02 12:00:00', Math.round(Math.random() * 500)],
['2023-10-02 13:00:00', Math.round(Math.random() * 500)],
['2023-10-02 14:00:00', Math.round(Math.random() * 500)],
['2023-10-02 15:00:00', Math.round(Math.random() * 500)],
['2023-10-03 08:00:00', Math.round(Math.random() * 500)],
['2023-10-03 09:00:00', Math.round(Math.random() * 500)],
['2023-10-03 10:00:00', Math.round(Math.random() * 500)],
['2023-10-03 11:00:00', Math.round(Math.random() * 500)],
['2023-10-03 12:00:00', Math.round(Math.random() * 500)],
['2023-10-03 13:00:00', Math.round(Math.random() * 500)],
['2023-10-03 14:00:00', Math.round(Math.random() * 500)],
['2023-10-03 15:00:00', Math.round(Math.random() * 500)],
['2023-10-04 08:00:00', Math.round(Math.random() * 500)],
['2023-10-04 09:00:00', Math.round(Math.random() * 500)],
['2023-10-04 10:00:00', Math.round(Math.random() * 500)],
['2023-10-04 11:00:00', Math.round(Math.random() * 500)],
['2023-10-04 12:00:00', Math.round(Math.random() * 500)],
['2023-10-04 13:00:00', Math.round(Math.random() * 500)],
['2023-10-04 14:00:00', Math.round(Math.random() * 500)],
['2023-10-04 15:00:00', Math.round(Math.random() * 500)],
['2023-10-05 08:00:00', Math.round(Math.random() * 500)],
['2023-10-05 09:00:00', Math.round(Math.random() * 500)],
['2023-10-05 10:00:00', Math.round(Math.random() * 500)],
['2023-10-05 11:00:00', Math.round(Math.random() * 500)],
['2023-10-05 12:00:00', Math.round(Math.random() * 500)],
['2023-10-05 13:00:00', Math.round(Math.random() * 500)],
['2023-10-05 14:00:00', Math.round(Math.random() * 500)],
['2023-10-05 15:00:00', Math.round(Math.random() * 500)],
['2023-10-06 08:00:00', Math.round(Math.random() * 500)],
['2023-10-06 09:00:00', Math.round(Math.random() * 500)],
['2023-10-06 10:00:00', Math.round(Math.random() * 500)],
['2023-10-06 11:00:00', Math.round(Math.random() * 500)],
['2023-10-06 12:00:00', Math.round(Math.random() * 500)],
['2023-10-06 13:00:00', Math.round(Math.random() * 500)],
['2023-10-06 14:00:00', Math.round(Math.random() * 500)],
['2023-10-06 15:00:00', Math.round(Math.random() * 500)],
['2023-10-07 08:00:00', Math.round(Math.random() * 500)],
['2023-10-07 09:00:00', Math.round(Math.random() * 500)],
['2023-10-07 10:00:00', Math.round(Math.random() * 500)],
['2023-10-07 11:00:00', Math.round(Math.random() * 500)],
['2023-10-07 12:00:00', Math.round(Math.random() * 500)],
['2023-10-07 13:00:00', Math.round(Math.random() * 500)],
['2023-10-07 14:00:00', Math.round(Math.random() * 500)],
['2023-10-07 15:00:00', Math.round(Math.random() * 500)]
]
},
{
name: '瞬时热量',
type: 'line',
smooth: true,
symbol: 'none',
yAxisIndex: 1,
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 100)],
['2023-10-01 09:00:00', Math.round(Math.random() * 100)],
['2023-10-01 10:00:00', Math.round(Math.random() * 100)],
['2023-10-01 11:00:00', Math.round(Math.random() * 100)],
['2023-10-01 12:00:00', Math.round(Math.random() * 100)],
['2023-10-01 13:00:00', Math.round(Math.random() * 100)],
['2023-10-01 14:00:00', Math.round(Math.random() * 100)],
['2023-10-01 15:00:00', Math.round(Math.random() * 100)],
['2023-10-02 08:00:00', Math.round(Math.random() * 100)],
['2023-10-02 09:00:00', Math.round(Math.random() * 100)],
['2023-10-02 10:00:00', Math.round(Math.random() * 100)],
['2023-10-02 11:00:00', Math.round(Math.random() * 100)],
['2023-10-02 12:00:00', Math.round(Math.random() * 100)],
['2023-10-02 13:00:00', Math.round(Math.random() * 100)],
['2023-10-02 14:00:00', Math.round(Math.random() * 100)],
['2023-10-02 15:00:00', Math.round(Math.random() * 100)],
['2023-10-03 08:00:00', Math.round(Math.random() * 100)],
['2023-10-03 09:00:00', Math.round(Math.random() * 100)],
['2023-10-03 10:00:00', Math.round(Math.random() * 100)],
['2023-10-03 11:00:00', Math.round(Math.random() * 100)],
['2023-10-03 12:00:00', Math.round(Math.random() * 100)],
['2023-10-03 13:00:00', Math.round(Math.random() * 100)],
['2023-10-03 14:00:00', Math.round(Math.random() * 100)],
['2023-10-03 15:00:00', Math.round(Math.random() * 100)],
['2023-10-04 08:00:00', Math.round(Math.random() * 100)],
['2023-10-04 09:00:00', Math.round(Math.random() * 100)],
['2023-10-04 10:00:00', Math.round(Math.random() * 100)],
['2023-10-04 11:00:00', Math.round(Math.random() * 100)],
['2023-10-04 12:00:00', Math.round(Math.random() * 100)],
['2023-10-04 13:00:00', Math.round(Math.random() * 100)],
['2023-10-04 14:00:00', Math.round(Math.random() * 100)],
['2023-10-04 15:00:00', Math.round(Math.random() * 100)],
['2023-10-05 08:00:00', Math.round(Math.random() * 100)],
['2023-10-05 09:00:00', Math.round(Math.random() * 100)],
['2023-10-05 10:00:00', Math.round(Math.random() * 100)],
['2023-10-05 11:00:00', Math.round(Math.random() * 100)],
['2023-10-05 12:00:00', Math.round(Math.random() * 100)],
['2023-10-05 13:00:00', Math.round(Math.random() * 100)],
['2023-10-05 14:00:00', Math.round(Math.random() * 100)],
['2023-10-05 15:00:00', Math.round(Math.random() * 100)],
['2023-10-06 08:00:00', Math.round(Math.random() * 100)],
['2023-10-06 09:00:00', Math.round(Math.random() * 100)],
['2023-10-06 10:00:00', Math.round(Math.random() * 100)],
['2023-10-06 11:00:00', Math.round(Math.random() * 100)],
['2023-10-06 12:00:00', Math.round(Math.random() * 100)],
['2023-10-06 13:00:00', Math.round(Math.random() * 100)],
['2023-10-06 14:00:00', Math.round(Math.random() * 100)],
['2023-10-06 15:00:00', Math.round(Math.random() * 100)],
['2023-10-07 08:00:00', Math.round(Math.random() * 100)],
['2023-10-07 09:00:00', Math.round(Math.random() * 100)],
['2023-10-07 10:00:00', Math.round(Math.random() * 100)],
['2023-10-07 11:00:00', Math.round(Math.random() * 100)],
['2023-10-07 12:00:00', Math.round(Math.random() * 100)],
['2023-10-07 13:00:00', Math.round(Math.random() * 100)],
['2023-10-07 14:00:00', Math.round(Math.random() * 100)],
['2023-10-07 15:00:00', Math.round(Math.random() * 100)]
] ]
},
{
name: '累计热量',
type: 'line',
smooth: true,
symbol: 'none',
yAxisIndex: 2,
data: [
['2023-10-01 08:00:00', Math.round(Math.random() * 500)],
['2023-10-01 09:00:00', Math.round(Math.random() * 500)],
['2023-10-01 10:00:00', Math.round(Math.random() * 500)],
['2023-10-01 11:00:00', Math.round(Math.random() * 500)],
['2023-10-01 12:00:00', Math.round(Math.random() * 500)],
['2023-10-01 13:00:00', Math.round(Math.random() * 500)],
['2023-10-01 14:00:00', Math.round(Math.random() * 500)],
['2023-10-01 15:00:00', Math.round(Math.random() * 500)],
['2023-10-02 08:00:00', Math.round(Math.random() * 500)],
['2023-10-02 09:00:00', Math.round(Math.random() * 500)],
['2023-10-02 10:00:00', Math.round(Math.random() * 500)],
['2023-10-02 11:00:00', Math.round(Math.random() * 500)],
['2023-10-02 12:00:00', Math.round(Math.random() * 500)],
['2023-10-02 13:00:00', Math.round(Math.random() * 500)],
['2023-10-02 14:00:00', Math.round(Math.random() * 500)],
['2023-10-02 15:00:00', Math.round(Math.random() * 500)],
['2023-10-03 08:00:00', Math.round(Math.random() * 500)],
['2023-10-03 09:00:00', Math.round(Math.random() * 500)],
['2023-10-03 10:00:00', Math.round(Math.random() * 500)],
['2023-10-03 11:00:00', Math.round(Math.random() * 500)],
['2023-10-03 12:00:00', Math.round(Math.random() * 500)],
['2023-10-03 13:00:00', Math.round(Math.random() * 500)],
['2023-10-03 14:00:00', Math.round(Math.random() * 500)],
['2023-10-03 15:00:00', Math.round(Math.random() * 500)],
['2023-10-04 08:00:00', Math.round(Math.random() * 500)],
['2023-10-04 09:00:00', Math.round(Math.random() * 500)],
['2023-10-04 10:00:00', Math.round(Math.random() * 500)],
['2023-10-04 11:00:00', Math.round(Math.random() * 500)],
['2023-10-04 12:00:00', Math.round(Math.random() * 500)],
['2023-10-04 13:00:00', Math.round(Math.random() * 500)],
['2023-10-04 14:00:00', Math.round(Math.random() * 500)],
['2023-10-04 15:00:00', Math.round(Math.random() * 500)],
['2023-10-05 08:00:00', Math.round(Math.random() * 500)],
['2023-10-05 09:00:00', Math.round(Math.random() * 500)],
['2023-10-05 10:00:00', Math.round(Math.random() * 500)],
['2023-10-05 11:00:00', Math.round(Math.random() * 500)],
['2023-10-05 12:00:00', Math.round(Math.random() * 500)],
['2023-10-05 13:00:00', Math.round(Math.random() * 500)],
['2023-10-05 14:00:00', Math.round(Math.random() * 500)],
['2023-10-05 15:00:00', Math.round(Math.random() * 500)],
['2023-10-06 08:00:00', Math.round(Math.random() * 500)],
['2023-10-06 09:00:00', Math.round(Math.random() * 500)],
['2023-10-06 10:00:00', Math.round(Math.random() * 500)],
['2023-10-06 11:00:00', Math.round(Math.random() * 500)],
['2023-10-06 12:00:00', Math.round(Math.random() * 500)],
['2023-10-06 13:00:00', Math.round(Math.random() * 500)],
['2023-10-06 14:00:00', Math.round(Math.random() * 500)],
['2023-10-06 15:00:00', Math.round(Math.random() * 500)],
['2023-10-07 08:00:00', Math.round(Math.random() * 500)],
['2023-10-07 09:00:00', Math.round(Math.random() * 500)],
['2023-10-07 10:00:00', Math.round(Math.random() * 500)],
['2023-10-07 11:00:00', Math.round(Math.random() * 500)],
['2023-10-07 12:00:00', Math.round(Math.random() * 500)],
['2023-10-07 13:00:00', Math.round(Math.random() * 500)],
['2023-10-07 14:00:00', Math.round(Math.random() * 500)],
['2023-10-07 15:00:00', Math.round(Math.random() * 500)]
] ]
} }
}
] ]
}; };
onMounted(() => { onMounted(() => {
// //
const chart = echarts.init(stackedRef.value); const chart = echarts.init(stackedRef.value);
chart.setOption(options); chart.setOption(options1);
getDevice();
getParam();
getPortion();
getDeviceInfo();
// //
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
chart.resize(); chart.resize();
}); });
}); });
function getDevice() {
//
const params = {};
getDevices().then((res: any) => {
if (res.code === 200) {
deviceData.value = res.data;
}
});
}
function getParam() {
//
const params = {};
getParams().then((res: any) => {
if (res.code === 200) {
parameterData.value = res.data;
}
});
}
function getPortion() {
//
const params = {};
getPortions().then((res: any) => {
if (res.code === 200) {
partitionData.value = res.data;
}
});
}
function getDeviceInfo() {
//线
const params = filterForm;
getDeviceInfos(params).then((res: any) => {
if (res.code === 200) {
}
});
}
function timeChange(res: any) {
//
filterForm.startTime = res[0];
filterForm.endTime = res[1];
}
function deviceChange(res: any) {
//
searchForm.parameter = [];
multipleLimit.value = res.length <= 1 ? 0 : 1;
filterForm.deviceUuid = res.toString();
}
function parameterChange(res: any) {
//
filterForm.paramCode = res.toString();
}
function partitionChange(res: string) {
//
filterForm.partion = res;
}
const submitForm = (formEl: FormInstance | undefined) => {
//
if (!formEl) return;
formEl.validate(valid => {
if (valid) {
getDeviceInfo();
console.log('submit:', filterForm);
} else {
console.log('error submit!');
return false;
}
});
};
const resetForm = (formEl: FormInstance | undefined) => {
//
if (!formEl) return;
formEl.resetFields();
filterForm.startTime = '';
filterForm.endTime = '';
filterForm.deviceUuid = '';
filterForm.paramCode = '';
filterForm.partion = '';
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import './index.scss'; @import './index.scss';

144
src/views/monitoring/screen/components/main.vue

@ -13,17 +13,39 @@
> --> > -->
<div class="mainTable" :style="{ height: `${sidebarHeight}px` }"> <div class="mainTable" :style="{ height: `${sidebarHeight}px` }">
<n-spin :show="loadingShow"> <n-spin :show="loadingShow">
<vxe-grid ref="tableRef" class="tableGrid" align="center" auto-resize keep-source :height="sidebarHeight - 4" <vxe-grid
header-row-class-name="headerRowClass" header-cell-class-name="headerCellClass" row-class-name="tableRowClass" ref="tableRef"
cell-class-name="tableCellClass" :sort-config="{ multiple: true, trigger: 'cell' }" :stripe="!tableBorder" :border="tableBorder" class="tableGrid"
:column-config="{ resizable: true, useKey: true }" :row-config="{ useKey: true }" :span-method="mergeRowMethod" align="center"
:columns="tableColumn" :data="tableData" @cell-dblclick="cellDBLClickEvent"> auto-resize
keep-source
:height="sidebarHeight - 4"
header-row-class-name="headerRowClass"
header-cell-class-name="headerCellClass"
row-class-name="tableRowClass"
cell-class-name="tableCellClass"
:sort-config="{ multiple: true, trigger: 'cell' }"
:stripe="!tableBorder"
:border="tableBorder"
:column-config="{ resizable: true, useKey: true }"
:row-config="{ useKey: true }"
:span-method="mergeRowMethod"
:columns="tableColumn"
:data="tableData"
@cell-dblclick="cellDBLClickEvent"
>
<template #deviceuuid_default="{ row }"> <template #deviceuuid_default="{ row }">
<div class="title"> <div class="title">
<svg-icon icon-class="warning_lights" style="fill:currentColor;width: 15px;height: 15px;color: green;" <svg-icon
v-if="row.deviceuuid.deviceStatus === 0" /> icon-class="warning_lights"
<svg-icon icon-class="warning_lights" style="fill:currentColor;width: 15px;height: 15px;color: red;" style="fill: currentColor; width: 15px; height: 15px; color: green"
v-if="row.deviceuuid.deviceStatus === 2" /> v-if="row.deviceuuid.deviceStatus === 0"
/>
<svg-icon
icon-class="warning_lights"
style="fill: currentColor; width: 15px; height: 15px; color: red"
v-if="row.deviceuuid.deviceStatus === 2"
/>
<span class="name" @click.native="nameClick(row.deviceuuid)">{{ row.gTitle }}</span> <span class="name" @click.native="nameClick(row.deviceuuid)">{{ row.gTitle }}</span>
</div> </div>
</template> </template>
@ -33,8 +55,17 @@
</div> </div>
<vxe-modal :title="modalTitle" v-model="editModal"> <vxe-modal :title="modalTitle" v-model="editModal">
<template #default> <template #default>
<vxe-form title-colon ref="formRef" title-align="right" title-width="100" :data="formData" :rules="formRules" <vxe-form
:loading="formLoading" @submit="submitEvent" @reset="resetEvent"> title-colon
ref="formRef"
title-align="right"
title-width="100"
:data="formData"
:rules="formRules"
:loading="formLoading"
@submit="submitEvent"
@reset="resetEvent"
>
<vxe-form-item field="value" span="24" :item-render="{}" title-overflow> <vxe-form-item field="value" span="24" :item-render="{}" title-overflow>
<template #default="params"> <template #default="params">
<vxe-input v-model="params.data.value" placeholder="请输入数值" clearable></vxe-input> <vxe-input v-model="params.data.value" placeholder="请输入数值" clearable></vxe-input>
@ -68,7 +99,7 @@ import { TableVo } from '@/api/table/types';
import { tableStore } from '@/store/modules/table'; import { tableStore } from '@/store/modules/table';
import mitt from '@/plugins/bus'; import mitt from '@/plugins/bus';
import socket from '@/utils/socket'; import socket from '@/utils/socket';
import useStorage from '@/utils/useStorage' import useStorage from '@/utils/useStorage';
const sessionStorageIns = useStorage('sessionStorage'); const sessionStorageIns = useStorage('sessionStorage');
const tableStoreCounter = tableStore(); const tableStoreCounter = tableStore();
@ -83,10 +114,10 @@ const menuKey = ref(0);
const tableColumn = ref([]); const tableColumn = ref([]);
const tableData = ref<TableVo[]>([]); const tableData = ref<TableVo[]>([]);
const tableRef = ref<VxeGridInstance<TableVo>>(); const tableRef = ref<VxeGridInstance<TableVo>>();
const cellRow = ref({}) const cellRow = ref({});
const cellColumn = ref() const cellColumn = ref();
const cellField = ref() const cellField = ref();
const tableBorder=ref(true) const tableBorder = ref(true);
// const fields = ref(['deviceuuid']) // // const fields = ref(['deviceuuid']) //
// const waringArrow = ref([]) // const waringArrow = ref([])
@ -102,7 +133,7 @@ const formData = ref<FormDataVO>({
//url: '', //url: '',
deviceName: '', deviceName: '',
paramCode: '', paramCode: '',
value: '', value: ''
}); });
const formRules = ref<VxeFormPropTypes.Rules>({ const formRules = ref<VxeFormPropTypes.Rules>({
value: [ value: [
@ -115,12 +146,12 @@ const formRules = ref<VxeFormPropTypes.Rules>({
if (!reg.test(itemValue)) { if (!reg.test(itemValue)) {
return new Error('请输入正确数值!'); return new Error('请输入正确数值!');
} }
}, }
}, }
], ]
}); });
const userStorageInfo = sessionStorage.getItem('userInfo') const userStorageInfo = sessionStorage.getItem('userInfo');
const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo); const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo);
//const apiUrl = import.meta.env.VITE_APP_WS_API //const apiUrl = import.meta.env.VITE_APP_WS_API
//const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket //const wsUrl = `${apiUrl}websocket/${userInfo.userName}`; //websocket
@ -130,7 +161,8 @@ const userInfo = JSON.parse(userStorageInfo === null ? '' : userStorageInfo);
// const baseApi = "http://board.heatiot.cn:8001/prod-api"//websocket // const baseApi = "http://board.heatiot.cn:8001/prod-api"//websocket
//const baseApi = import.meta.env.VITE_APP_BASE_API //const baseApi = import.meta.env.VITE_APP_BASE_API
//const apiUrl = baseApi.replace(/https?:/, ''); //const apiUrl = baseApi.replace(/https?:/, '');
const wsUrl = `ws://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket // const wsUrl = `ws://${window.location.host}/ws/websocket/${userInfo.userName}`; //websocket
const wsUrl = `ws://10.10.10.56:9010/websocket/${userInfo.userName}`; //websocket
const emit = defineEmits(['tableHeaderData']); const emit = defineEmits(['tableHeaderData']);
// const listData = ref([ // const listData = ref([
@ -143,12 +175,12 @@ const emit = defineEmits(['tableHeaderData']);
defineProps({ defineProps({
tapsShow: { tapsShow: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
sidebarHeight: { sidebarHeight: {
type: Number, type: Number,
default: 0, default: 0
}, }
}); });
// watch( // watch(
@ -205,18 +237,18 @@ mitt.on('treeData', (res: any) => {
mitt.on('tableMessage', (res: any) => { mitt.on('tableMessage', (res: any) => {
// //
console.log("tableMessage--", res.data); console.log('tableMessage--', res.data);
const $table = tableRef.value; const $table = tableRef.value;
const tableArray = tableData.value const tableArray = tableData.value;
if ($table) { if ($table) {
console.log("tableRef--", tableRef.value) console.log('tableRef--', tableRef.value);
res.data.map((item: any) => { res.data.map((item: any) => {
const index = tableArray.findIndex((obj) => obj.id === item.id); const index = tableArray.findIndex(obj => obj.id === item.id);
if (index !== -1) { if (index !== -1) {
tableArray.splice(index, 1, item); tableArray.splice(index, 1, item);
} }
}) });
console.log("tableData--", tableArray) console.log('tableData--', tableArray);
$table.loadData(tableArray); $table.loadData(tableArray);
// if (res.code === 'datareal') { // if (res.code === 'datareal') {
// const index = tableData.value.findIndex((obj) => obj.id === res.data.id); // const index = tableData.value.findIndex((obj) => obj.id === res.data.id);
@ -262,9 +294,9 @@ function tableHeader() {
type: 'html', type: 'html',
formatter: formatRole, formatter: formatRole,
visible: false visible: false
}, }
]; ];
console.log(tableCessText) console.log(tableCessText);
res.data.map((item: any) => { res.data.map((item: any) => {
if (item.formatter != undefined || item.children != undefined) { if (item.formatter != undefined || item.children != undefined) {
item.formatter = eval(item.formatter); item.formatter = eval(item.formatter);
@ -327,19 +359,19 @@ const cellDBLClickEvent: VxeTableEvents.CellDblclick<TableVo> = ({ row, column }
//edit ty zhousq 2023-10-12 formdata //edit ty zhousq 2023-10-12 formdata
// ctrlPro.centeruuid UUID cellField.ctrlPro.paramcode cellField.val // ctrlPro.centeruuid UUID cellField.ctrlPro.paramcode cellField.val
//ctrlPro //ctrlPro
console.log("cellData--", row, column); console.log('cellData--', row, column);
const cellField = row[column.field]; const cellField = row[column.field];
//const data = row.data; //const data = row.data;
cellRow.value = row cellRow.value = row;
cellColumn.value = column cellColumn.value = column;
cellField.value = cellField cellField.value = cellField;
if (cellField.canBeControl === '1') { if (cellField.canBeControl === '1') {
modalTitle.value = column.title; modalTitle.value = column.title;
///formData.value.url = data.url; ///formData.value.url = data.url;
//formData.value.deviceName = cellField.deviceName; //formData.value.deviceName = cellField.deviceName;
formData.value.value = cellField.val; formData.value.value = cellField.val;
formData.value.deviceName=cellField.ctrlPro.centeruuid formData.value.deviceName = cellField.ctrlPro.centeruuid;
formData.value.paramCode=cellField.ctrlPro.paramcode formData.value.paramCode = cellField.ctrlPro.paramcode;
editModal.value = true; editModal.value = true;
} }
console.log(row[column.field]); console.log(row[column.field]);
@ -349,30 +381,34 @@ const formatRole: VxeColumnPropTypes.Formatter<HeaderVo> = ({ cellValue }) => {
//object //object
// const iconFont=cellValue.changeProp===-1?'<i class="iconfont icon-decline" />':(cellValue.changeProp===1?'<i class="iconfont icon-rise" />':'<i/>') // const iconFont=cellValue.changeProp===-1?'<i class="iconfont icon-decline" />':(cellValue.changeProp===1?'<i class="iconfont icon-rise" />':'<i/>')
// const cellData = `<span class="cellClass ${cellValue.alertProp===1?'warning':''}">${cellValue.val}</span>${iconFont}`; // const cellData = `<span class="cellClass ${cellValue.alertProp===1?'warning':''}">${cellValue.val}</span>${iconFont}`;
const cellData = `<span class="cellClass ${cellValue.alertProp === 1 ? 'warning' : (cellValue.canBeControl === '1' ? 'cellEdit' : '')}">${cellValue.val}</span><i class="iconfont ${cellValue.changeProp === -1 ? 'icon-decline' : (cellValue.changeProp === 1 ? 'icon-rise' : '')}" ></i>${cellValue.canBeControl === '1' ? '<i class="iconfont icon-edit-icon"></i>' : ''}`; const cellData = `<span class="cellClass ${
cellValue.alertProp === 1 ? 'warning' : cellValue.canBeControl === '1' ? 'cellEdit' : ''
}">${cellValue.val}</span><i class="iconfont ${
cellValue.changeProp === -1 ? 'icon-decline' : cellValue.changeProp === 1 ? 'icon-rise' : ''
}" ></i>${cellValue.canBeControl === '1' ? '<i class="iconfont icon-edit-icon"></i>' : ''}`;
return cellData; return cellData;
}; };
// //
const mergeRowMethod: VxeTablePropTypes.SpanMethod<TableVo> = ({ row, _rowIndex, column, visibleData }) => { const mergeRowMethod: VxeTablePropTypes.SpanMethod<TableVo> = ({ row, _rowIndex, column, visibleData }) => {
const fields = ['gTitle'] const fields = ['gTitle'];
const cellValue = row[column.field] const cellValue = row[column.field];
if (cellValue && fields.includes(column.field)) { if (cellValue && fields.includes(column.field)) {
const prevRow = visibleData[_rowIndex - 1] const prevRow = visibleData[_rowIndex - 1];
let nextRow = visibleData[_rowIndex + 1] let nextRow = visibleData[_rowIndex + 1];
if (prevRow && prevRow[column.field] === cellValue) { if (prevRow && prevRow[column.field] === cellValue) {
return { rowspan: 0, colspan: 0 } return { rowspan: 0, colspan: 0 };
} else { } else {
let countRowspan = 1 let countRowspan = 1;
while (nextRow && nextRow[column.field] === cellValue) { while (nextRow && nextRow[column.field] === cellValue) {
nextRow = visibleData[++countRowspan + _rowIndex] nextRow = visibleData[++countRowspan + _rowIndex];
} }
if (countRowspan > 1) { if (countRowspan > 1) {
return { rowspan: countRowspan, colspan: 1 } return { rowspan: countRowspan, colspan: 1 };
}
} }
} }
} }
};
const submitEvent: VxeFormEvents.Submit = () => { const submitEvent: VxeFormEvents.Submit = () => {
//websocket //websocket
@ -386,7 +422,7 @@ const submitEvent: VxeFormEvents.Submit = () => {
//value: formData.value.value, //value: formData.value.value,
deviceUUID: formData.value.deviceName, deviceUUID: formData.value.deviceName,
paramCode: formData.value.paramCode, paramCode: formData.value.paramCode,
valueType: "", valueType: '',
value: formData.value.value value: formData.value.value
//}, //},
}; };
@ -402,10 +438,10 @@ const submitEvent: VxeFormEvents.Submit = () => {
editModal.value = false; editModal.value = false;
if ($table) { if ($table) {
const row = cellRow.value const row = cellRow.value;
const field = cellColumn.value.field; const field = cellColumn.value.field;
row[field].val = formData.value.value row[field].val = formData.value.value;
$table.reloadRow(row, null, field) $table.reloadRow(row, null, field);
} }
// VXETable.modal.message({ content: '', status: 'success' }); // VXETable.modal.message({ content: '', status: 'success' });
@ -413,7 +449,7 @@ const submitEvent: VxeFormEvents.Submit = () => {
function nameClick(row: any) { function nameClick(row: any) {
// //
console.log(row) console.log(row);
sessionStorageIns.setUseStorage('id', row.id); sessionStorageIns.setUseStorage('id', row.id);
router.push({ path: '/devicemanage', query: { id: row.id } }); router.push({ path: '/devicemanage', query: { id: row.id } });
} }

6
vite.config.ts

@ -45,9 +45,9 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
hmr: true, //配置HMR hmr: true, //配置HMR
proxy: { proxy: {
[env.VITE_APP_BASE_API]: { [env.VITE_APP_BASE_API]: {
target: 'http://172.1.2.196:9010/',//本地接口地址 // target: 'http://172.1.2.196:9010/', //本地接口地址
// target: 'http://172.1.2.48:9000/',//本地接口地址 target: 'http://172.1.2.93:9010/', //本地接口地址
// target: 'http://board.heatiot.cn:8001/prod-api/', //线上接口地址 // target: 'http://10.10.10.56:9010/', //线上测试接口地址
changeOrigin: true, changeOrigin: true,
rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '') rewrite: path => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')
} }

Loading…
Cancel
Save