浏览代码

2023-02-20 update

1. 调整温度功率曲线分析  增加多选功能
moccus 2 年之前
父节点
当前提交
f878d13e8a
共有 1 个文件被更改,包括 65 次插入276 次删除
  1. 65 276
      src/pages/lightAnalysis/glHotAnalysis/index.vue

+ 65 - 276
src/pages/lightAnalysis/glHotAnalysis/index.vue

@@ -1,30 +1,26 @@
 <script setup name="prepare">
 import excelCop from '@/components/excel.vue'
 import treeCop from '@/components/tree.vue'
-import tableCop from './components/table.vue'
+// import tableCop from './components/table.vue'
 import { ref, nextTick, onActivated, onMounted, reactive } from 'vue'
 import request from '@/api/axios.js'
-import util from "@tools/util";
+import {ElMessage} from 'element-plus'
 import CurrentScatterChart from './components/current-scatter-chart.vue'
-// import dotRes from '@/data/dot.json'
-// import tableRes from '@/data/table.json'
-// import areaDataRes from '@/data/areaData.json'
 /**配置参数 */
 const treeHeight = ref(window.innerHeight - 150 + 'px') //tree高度
 const excelHeight = ref(window.innerHeight - 150 + 'px') //excel高度
-const tableHeight = ref(window.innerHeight - 204 + 'px')
-/**excel 开始 */
-const excelCheckboxShow = ref(false)
-const excelType = ref('')
-const excelCheckIds = ref([])
-const excelList = ref([])
-const funExcelChange = async (obj) => { //点击excel项时
-	isChartArea.value = false
-	tableShowId.value = obj.id
-	tableName.value = obj.name
-	excelType.value = obj.type // 接收excel的type 用于控制右侧tab展示
+const tableHeight = ref(window.innerHeight - 150 + 'px')
 
-	let res = null
+/**submit */
+const funSubmit = async () => {
+	if (!excelCheckIds.value.length) {
+		ElMessage.error('请勾选要执行的项')
+		return false
+	}
+	// tableShowId.value = '1'
+	// tableName.value = obj.name
+
+	// let res = null
 	let chartRes = {
 		scatterhs: [[]],
 		scatterls: [[]],
@@ -33,37 +29,27 @@ const funExcelChange = async (obj) => { //点击excel项时
 		cpz: [[]]
 	}
 	let chartResponse = null
-	tableLoading.value = true
-	res = await request.get('/datas', { params: { filename: obj.id } })
-	// res = tableRes
-	// chartResponse = dotRes
-	chartResponse = await request.get('/analysis/powerbeam', { params: { filename: obj.id} })
-	if(res.code === 200){
-		tableColumn.value = res.data.title.map(o => {
-			return {
-				prop: o.key,
-				width: o.des==='时间'? 100: 80,
-				label: o.des,
-			}
-		})
-		tableData.value = res.data.data
-		tableLoading.value = false
-	}else{
-		tableLoading.value = false
-	}
+	// tableLoading.value = true
+	// res = await request.get('/datas', { params: { filename: obj.id } })
+	chartResponse = await request.post('/analysis/powerbeam', { filename: excelCheckIds.value.join() })
+	// if(res.code === 200){
+	// 	tableColumn.value = res.data.title.map(o => {
+	// 		return {
+	// 			prop: o.key,
+	// 			width: o.des==='时间'? 100: 80,
+	// 			label: o.des,
+	// 		}
+	// 	})
+	// 	tableData.value = res.data.data
+	// 	tableLoading.value = false
+	// }else{
+	// 	tableLoading.value = false
+	// }
 
 	if (chartResponse && chartResponse.code === 200) {
-		activeTab.value = '2'
+		// activeTab.value = '2'
 		nextTick(() => {
 			chartRes = chartResponse.data
-			// markDot.pcl5 = chartRes.obj.pc5ratio
-			// markDot.pcl10 = chartRes.obj.pc10ratio
-			// markDot.pcl12 = chartRes.obj.pc12ratio
-			// markDot.pcl25 = chartRes.obj.pc25ratio
-			// avgObj.title = chartRes.obj.path.substring(chartRes.obj.path.indexOf(chartRes.obj.station + '_') + (chartRes.obj.station + '_').length).split('_')[0];
-			// avgObj.cpavg = Number(chartRes.obj.cpavg).toFixed(2)
-			// avgObj.frequency = Number(chartRes.obj.frequency).toFixed(2)
-			// avgObj.pcratio = Number(chartRes.obj.pcratio).toFixed(2)
 			seriesData.value = [
 				{
 					name: "拟合功率",
@@ -81,14 +67,6 @@ const funExcelChange = async (obj) => { //点击excel项时
 						scale: 1
 					},
 					name: '数据散点',
-					// symbolSize: (data) => {
-					// 	return data.s ? data.s > 10 ? 10 : data.s : 4
-					// },
-					// datasetIndex: 1,
-					// encode: {
-					// 	x: 'x',
-					// 	y: 'y'
-					// },
 					data: chartRes.scatter,
 					xAxisIndex: 0,
 					yAxisIndex: 0,
@@ -97,6 +75,15 @@ const funExcelChange = async (obj) => { //点击excel项时
 		})
 	}
 }
+/**excel 开始 */
+const excelCheckIds = ref([])
+const funExcelChange = async (obj) => { //点击excel项时
+	return false
+}
+const funExcelCheckChange = ({ checkArr, data }) => {   //bug 
+	excelCheckIds.value = checkArr
+	funSubmit()
+}
 /**excel fitData */
 const excelFitList = ref([])
 /**prepare tree 开始 */
@@ -119,27 +106,6 @@ const funRepeatMap = (arr, type='prepare') => {
 		}
 	})
 }
-const funCurrentChange = ({ current, currentNode }) => {
-	excelCheckboxShow.value = true
-	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
-			}
-		})
-	} else {
-		excelList.value = []
-	}
-}
-
 /**process tree 开始 */
 const processTreeData = ref([])
 const funGetProcessTree = async (flag = true) => { //flag控制是否获取tree的第一项 true为可获取
@@ -181,6 +147,21 @@ const funProcessCurrentChange = ({ current, currentNode }) => {
 		excelFitList.value = []
 	}
 }
+const funTreeCheckChange = ({ current, checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) => {  //tree change  -> excel change
+	funProcessCurrentChange({ current, currentNode: '' })
+	const checkIds = []
+	if (checkedNodes.length) {
+		for (const node of checkedNodes) {
+			if (node.childs && node.childs.length) {
+				for (const child of node.childs) {
+					checkIds.push(child.id)
+				}
+			}
+		}
+	}
+	excelCheckIds.value = checkIds
+	funSubmit()
+}
 
 /**table 开始 */
 const tableShowId = ref('')
@@ -190,182 +171,10 @@ const tableName = ref('')
 const tableData = ref([])
 /**table 结束 */
 /**chart Data */
-const avgObj = reactive({ //平均cpz等
-	title: '',
-	cpavg: '',
-	frequency: '',
-	pcratio: ''
-})
-const markDot = reactive({ //3-5 point点等
-	pcl5: null,
-	pcl10: null,
-	pcl12: null,
-	pcl25: null
-})
 const xAxisData = ref([])
 const chartRef = ref() //chart 的ref
 const seriesData = ref([])
-const isChartArea = ref(false) // 用来控制图表是否区域划分
 const dataSet = ref('')
-const funChartSelect = async (batch) => {
-	const wDataArr = []
-	const yDataArr = []
-	let scatterls = []
-	let scatterhs = []
-	let dataSetObj = []
-	wtData.value = []
-	if (batch?.length && dataSet.value) {
-		scatterls = batch[0].selected[2].dataIndex
-		scatterhs = batch[0].selected[3].dataIndex
-		if (scatterls?.length || scatterhs?.length) {
-			dataSetObj = JSON.parse(dataSet.value)
-			if (scatterls?.length) {
-				for (const scatterIndex of scatterls) {
-					wDataArr.push(dataSetObj[0].source[scatterIndex].k)
-				}
-			}
-			if (scatterhs?.length) {
-				for (const scatterIndex of scatterhs) {
-					yDataArr.push(dataSetObj[1].source[scatterIndex].k)
-				}
-			}
-			const wtRes = await request.get('/power/fitting/filter', { params: { yk: yDataArr.join(','), wk: wDataArr.join(',') } })
-			if (wtRes.code === 200) {
-				let id = 1
-				const tempArr = [] //用于以风机id 聚合dataArr
-				if (wtRes.data?.length) {
-					for (const data of wtRes.data) {
-						if (tempArr.length) {
-							const findIndex = tempArr.findIndex(o => o.wtId === data.wtId)
-							if (findIndex !== -1) {
-								if (!tempArr[findIndex].children) {
-									tempArr[findIndex].children = []
-								}
-								tempArr[findIndex].children.push({ ...data, id: id, filter: data.filter === 0 ? '是' : '否' })
-								id++
-							} else {
-								tempArr.push({ ...data, id: id, filter: data.filter === 0 ? '是' : '否' })
-								id++
-							}
-						} else {
-							tempArr.push({ ...data, id: id, filter: data.filter === 0 ? '是' : '否' })
-							id++
-						}
-					}
-					wtDialog.value = true
-					nextTick(() => {
-						wtTab.value = 'table'
-						wtData.value = tempArr
-					})
-				}
-			}
-		}
-	}
-}
-const funChartArea = () => {
-	if (seriesData.value?.length) {
-		if (!isChartArea.value) {
-			// 请求一下
-			seriesData.value[0] = {
-					...seriesData.value[0],
-					markLine: {
-						symbol: 'none',
-						label: {
-							show: false
-						},
-						lineStyle: {
-							color: 'rgba(96,174,255, 1)'
-						},
-						data: [
-							{
-								xAxis: 3,
-								valueIndex: 0,
-							},
-							{
-								xAxis: 5,
-								valueIndex: 0
-							},
-							{
-								xAxis: 10,
-								valueIndex: 0
-							},
-							{
-								xAxis: 12,
-								valueIndex: 0
-							},
-							{
-								xAxis: 25,
-								valueIndex: 0
-							},
-						]
-					},
-					markArea: {
-						label: {
-							fontSize: util.vh(12),
-						},
-						itemStyle: {
-							color: 'rgba(236,245,255, 0)'
-						},
-						emphasis: {
-							itemStyle: {
-								color: 'rgba(96,174,255, 0.5)'
-							}
-						},
-						data: [
-							[
-								{
-									name: `3~5m 偏差率: ${markDot.pcl5}%`,
-									xAxis: 3,
-								},
-								{
-									xAxis: 5,
-								}
-							],
-							[
-								{
-									name: `5~10m 偏差率: ${markDot.pcl10}%`,
-									xAxis: 5,
-								},
-								{
-									xAxis: 10,
-								}
-							],
-							[
-								{
-									name: `10~12m 偏差率: ${markDot.pcl12}%`,
-									xAxis: 10,
-								},
-								{
-									xAxis: 12,
-								}
-							],
-							[
-								{
-									name: `12~25m 偏差率: ${markDot.pcl25}%`,
-									xAxis: 12,
-								},
-								{
-									xAxis: 25,
-								}
-							],
-						]
-					},
-				}
-			isChartArea.value = true
-		} else {
-			seriesData.value[0] = {
-					...seriesData.value[0],
-					markLine: null,
-					markArea: null,
-				}
-			isChartArea.value = false
-		}
-	}
-}
-/**dialog 数据 */
-const wtDialog = ref(false)
-const wtData = ref([])
-const wtTab = ref('table')
 /**tab  */
 const activeTab = ref('1')
 /**created */
@@ -373,11 +182,11 @@ const activeTab = ref('1')
 // funGetProcessTree()
 /**mounted */
 onMounted(() => {
-	tableHeight.value = window.innerHeight - 204 + 'px'
+	tableHeight.value = window.innerHeight - 150 + 'px'
 	excelHeight.value =(window.innerHeight - 150) + 'px'
 	treeHeight.value = (window.innerHeight - 150) + 'px'
 	window.addEventListener('resize', () => {
-		tableHeight.value = window.innerHeight - 204 + 'px'
+		tableHeight.value = window.innerHeight - 150 + 'px'
 		excelHeight.value = (window.innerHeight - 150) + 'px'
 		treeHeight.value = (window.innerHeight - 150)  + 'px'
 	})
@@ -395,54 +204,34 @@ onActivated(() => {
 </script>
 <template>
 	<div class="bg-white py-[10px] px-[10px]">
-		<el-dialog v-model="wtDialog" draggable title="风机功率点位">
-			<el-tabs v-model="wtTab">
-				<el-tab-pane label="数据" name="table">
-					<el-table :data="wtData" row-key="id" :max-height="550">
-						<el-table-column property="wtId" align="center" label="风机" />
-						<el-table-column property="time" sortable :width="160" align="center" label="时间" />
-						<el-table-column property="speed" sortable align="center" label="风速(m/s)" />
-						<el-table-column property="power" sortable align="center" label="功率(kW)" />
-						<el-table-column property="rr" sortable align="center" label="转速" />
-						<el-table-column property="filter" sortable align="center" label="是否有用点" />
-					</el-table>
-				</el-tab-pane>
-				<el-tab-pane label="故障" name="problem" disabled>
-
-				</el-tab-pane>
-				<el-tab-pane label="预警" name="warning" disabled>
-
-				</el-tab-pane>
-			</el-tabs>
-		</el-dialog>
 		<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="processTreeData" :height="treeHeight"
-						@currentChange="funProcessCurrentChange" @refresh="funGetProcessTree"></tree-cop>
+					<tree-cop :data="processTreeData" :height="treeHeight" @checkChange="funTreeCheckChange"
+            :show-checkbox="true" @currentChange="funProcessCurrentChange" @refresh="funGetProcessTree"></tree-cop>
 				</el-col>
 				<el-col :span="3">
-					<excel-cop :data="excelFitList" :height="excelHeight" @excelChange="funExcelChange">
+					<excel-cop :data="excelFitList" :checkIds="excelCheckIds" :showCheckbox="true" :height="excelHeight" @excelChange="funExcelChange" @checkChange="funExcelCheckChange">
 					</excel-cop>
 				</el-col>
 				<el-col :span="16">
 					<div class="px-[10px] shadow rounded-[6px] shadow-blue-500 ">
-						<el-tabs v-model="activeTab">
-							<el-tab-pane label="表格数据" name="1">
+						<!-- <el-tabs v-model="activeTab"> -->
+							<!-- <el-tab-pane label="表格数据" name="1">
 							</el-tab-pane>
 							<el-tab-pane label="图表展示" name="2">
 							</el-tab-pane>
 							<table-cop v-show="activeTab === '1'" :data="tableData" :loading="tableLoading" :column="tableColumn"
-								:height="tableHeight" :tableId="tableShowId" :tableName="tableName"></table-cop>
-							<div v-show="activeTab === '2'"
+								:height="tableHeight" :tableId="tableShowId" :tableName="tableName"></table-cop> -->
+							<div
 								:style="{ height: typeof tableHeight === 'string' ? tableHeight : tableHeight + 'px' }"
 								class="p-[10px]">
 								<CurrentScatterChart ref="chartRef" width="100%" :height="`calc( ${tableHeight} - 20px )`" :chartTitle="''"
 									:xAxisData="xAxisData" :yAxisData="{ splitLine: { show: false } }" :seriesData="seriesData"
-									:showLegend="true" :brushSelected="false" :dataSet="dataSet" @getSelected="funChartSelect" />
+									:showLegend="true" :brushSelected="false" :dataSet="dataSet"/>
 							</div>
-						</el-tabs>
+						<!-- </el-tabs> -->
 					</div>
 				</el-col>
 			</el-row>