123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <script setup name="prepare">
- import searchCop from './components/search.vue'
- import excelCop from '@/components/excel.vue'
- import treeCop from '@/components/tree.vue'
- import { ElMessage } from 'element-plus';
- import { onMounted, ref, onActivated } from 'vue'
- import CurrentScatterChart from './components/current-scatter-chart.vue'
- import request from '@/api/axios.js'
- import {baseURL, socketURL} from '@/api/axios.js'
- import dayjs from 'dayjs';
- const tableHeight = ref(window.innerHeight - 160 + 'px')
- const treeHeight = ref(window.innerHeight - 160 + 'px')
- const excelHeight = ref(window.innerHeight - 160 + 'px')
- const excelList = ref([])
- const funExcelChange = async (obj) => {
- funSubmit({ids: obj.id})
- }
- const treeData = ref([])
- const actTreeNode = ref(null)
- const funRepeatMap = (arr, type) => {
- return arr.map(o => {
- if (o.children) {
- const findIndex = o.children.findIndex(p => !!p.type)
- if (findIndex !== -1) {
- o.childs = o.children
- o.children = []
- if(!actTreeNode.value && type === 'prepare'){
- actTreeNode.value = o
- }
- }
- }
- return {
- ...o,
- children: o.children?.length ? funRepeatMap(o.children, type) : []
- }
- })
- }
- const funGetTree = async () => {
- const res = await request.get("/power/prepare/tree")
- treeData.value = funRepeatMap(res.data, 'prepare')
- excelList.value = []
- if(actTreeNode.value){
- funCurrentChange({current: actTreeNode.value, currentNode: null})
- const child = actTreeNode.value.childs[0]
- const obj = {
- id: child.id,
- interval: child.interval,
- path: child.path,
- prepareid: child.prepareid,
- station: child.station,
- time: child.time,
- type: child.type,
- windturbine: child.windturbine,
- name: child.path.substring(child.path.indexOf(child.station + '_') + (child.station + '_').length)
- }
- funExcelChange(obj)
- }
- }
- const funCurrentChange = ({ current, currentNode }) => {
- if (current.childs) {
- excelList.value = current.childs.map(o => {
- return {
- id: o.id,
- interval: o.interval,
- path: o.path,
- prepareid: o.prepareid,
- station: o.station,
- time: o.time,
- type: o.type,
- windturbine: o.windturbine,
- name: o.path.substring(o.path.indexOf(o.station + '_') + (o.station + '_').length)
- }
- })
- } else {
- excelList.value = []
- }
- }
- const tableShowId = ref('')
- const tableName = ref('')
- const tableColumn = ref([])
- const tableLoading = ref(false)
- const tableData = ref([])
- const activeTab = ref('1')
- const xAxisData = ref([])
- const chartRef = ref()
- const seriesData = ref([])
- const dataSet = ref('')
- const funChartSelect = async (batch) => {
- return false
- }
- const funSubmit = async (params) => {
-
- const res = await request.get('/blade/angle', { params: params })
- if(res.code !== 200){
- return false
- }
- const tsArr = res.data.time
- let yp1 = [], yp2 = [], yp3 = []
- res.data.angle.forEach(val => {
- yp1 = val.yp1
- yp2 = val.yp2
- yp3 = val.yp3
- });
- xAxisData.value = tsArr
- seriesData.value = [
- {
- name: "叶片一",
- type: "line",
- symbol: "line",
- symbolSize: 0,
- smooth: false,
- data: yp1,
- xAxisIndex: 0,
- },
- {
- name: "叶片二",
- type: "line",
- symbol: "line",
- symbolSize: 0,
- smooth: false,
- data: yp2,
- xAxisIndex: 0,
- },
- {
- name: "叶片三",
- type: "line",
- symbol: "line",
- symbolSize: 0,
- smooth: false,
- data: yp3,
- xAxisIndex: 0,
- },
- ]
- }
- onMounted(() => {
- tableHeight.value = window.innerHeight - 160 + 'px'
- excelHeight.value = window.innerHeight - 160 + 'px'
- treeHeight.value = window.innerHeight - 160 + 'px'
- window.addEventListener('resize', () => {
- tableHeight.value = window.innerHeight - 160 + 'px'
- excelHeight.value = window.innerHeight - 160 + 'px'
- treeHeight.value = window.innerHeight - 160 + 'px'
- })
- })
- onActivated(() => {
- funGetTree()
-
- })
- </script>
- <template>
- <div class="bg-white py-[10px] px-[10px] relative">
-
- <div class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[20px] pb-[10px]">
- <div class="text-[14px] absolute top-[-7px] text-[#838383] left-[20px]">数据展示</div>
- <el-row :gutter="10">
- <el-col :span="5">
- <tree-cop :data="treeData" :height="treeHeight" @currentChange="funCurrentChange" @refresh="funGetTree">
- </tree-cop>
- </el-col>
- <el-col :span="3">
- <excel-cop :data="excelList" :height="excelHeight" @excelChange="funExcelChange"></excel-cop>
- </el-col>
- <el-col :span="16">
- <div class="px-[10px] shadow rounded-[6px] shadow-blue-500 ">
- <CurrentScatterChart ref="chartRef" width="100%" :height="`calc( ${tableHeight})`" :chartTitle="''"
- :xAxisData="xAxisData" :yAxisData="{ splitLine: { show: false } }" :seriesData="seriesData"
- :showLegend="true" :brushSelected="false" :dataSet="dataSet" @getSelected="funChartSelect" />
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
|