Browse Source

2022-12-05 update bug fix

1. combine 偏差率获取由chartResponse返回
2. lineAnalysis 区域划分表格数据与seriesData 同时获取
3. rateAnalysis chart/lineChart/scatterSingleChart 调整mounted时, echarts获取不到百分比宽度的问题.
4. rateAnalysis 调整dialog时, 单图表展示时部分图表属性变化
moccus 2 years ago
parent
commit
c4e99625d1

+ 4 - 11
src/pages/dataAnalysis/combine/index.vue

@@ -36,7 +36,6 @@ const funExcelChange = async (obj) => { //点击excel项时
 		llgl: [[]],
 		cpz: [[]]
 	}
-	let poiRes = null
 	let chartResponse = null
 	tableLoading.value = true
 	if (obj.type === 'process') {
@@ -47,8 +46,6 @@ const funExcelChange = async (obj) => { //点击excel项时
 		// res = tableRes
 		// chartResponse = dotRes
 		chartResponse = await request.get('/power/fitting/curve', { params: { id: obj.id, p: 1 } })
-		poiRes = await request.get('/power/fitting/curve/ratio', {params: {id: obj.id}})
-		// poiRes = areaDataRes
 	}
 	tableColumn.value = res.data.title.map(o => {
 		return {
@@ -60,16 +57,12 @@ const funExcelChange = async (obj) => { //点击excel项时
 	tableData.value = res.data.data
 	tableLoading.value = false
 
-	// markDot 
-	if(poiRes && poiRes.code=== 200){
-		markDot.pcl5 = poiRes.data.pcl5
-		markDot.pcl10 = poiRes.data.pcl10
-		markDot.pcl12 = poiRes.data.pcl12
-		markDot.pcl25 = poiRes.data.pcl25
-	}
-
 	if (chartResponse && chartResponse.code === 200) {
 		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)

+ 14 - 71
src/pages/dataAnalysis/lineAnalysis/index.vue

@@ -93,6 +93,7 @@ const funSubmit = async () => {
 		ElMessage.error('请勾选要预处理的项')
 		return false
 	}
+	wtData.value = []
 	const params = {
 		ids: excelCheckIds.value.join(',')
 	}
@@ -116,7 +117,7 @@ const funSubmit = async () => {
 			for(const wtObj of res.data.sjgl){
 				seriesData.value.push(
 					{
-						name: wtObj.wtId + "\n实际功率",
+						name: wtObj.obj.windturbine + "\n实际功率",
 						type: "line",
 						symbol: "line", //设定为实心点
 						symbolSize: 0, //设定实心点的大小
@@ -125,6 +126,7 @@ const funSubmit = async () => {
 						xAxisIndex: 0,
 					},
 				)
+				wtData.value.push(wtObj.obj)
 			}
 		}
 	}
@@ -135,77 +137,18 @@ const avgObj = reactive({ //平均cpz等
 	frequency: '',
 	pcratio: ''
 })
-const markDot = reactive({ //3-5 point点等
-	pcl5: 0,
-	pcl10: 0,
-	pcl12: 0,
-	pcl25: 0
-})
 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
-					})
-				}
-			}
-		}
-	}
+	return false
 }
 const funChartArea = () => {
 	if (seriesData.value?.length) {
 		// 获取数据后 展示dialog table 数据
 		wtDialog.value = true
-		wtData.value = []
 		if (!isChartArea.value) {
 			// 请求一下
 			seriesData.value[0] = {
@@ -256,7 +199,7 @@ const funChartArea = () => {
 						data: [
 							[
 								{
-									name: `3~5m 偏差率: ${markDot.pcl5}%`,
+									name: `3~5m`,
 									xAxis: 3,
 								},
 								{
@@ -265,7 +208,7 @@ const funChartArea = () => {
 							],
 							[
 								{
-									name: `5~10m 偏差率: ${markDot.pcl10}%`,
+									name: `5~10m`,
 									xAxis: 5,
 								},
 								{
@@ -274,7 +217,7 @@ const funChartArea = () => {
 							],
 							[
 								{
-									name: `10~12m 偏差率: ${markDot.pcl12}%`,
+									name: `10~12m`,
 									xAxis: 10,
 								},
 								{
@@ -283,7 +226,7 @@ const funChartArea = () => {
 							],
 							[
 								{
-									name: `12~25m 偏差率: ${markDot.pcl25}%`,
+									name: `12~25m`,
 									xAxis: 12,
 								},
 								{
@@ -337,33 +280,33 @@ onActivated(() => {
   <div class="bg-white py-[10px] px-[10px]">
     <el-dialog draggable v-model="wtDialog" title="曲线偏差率">
 			<el-table :data="wtData" row-key="id" :max-height="550">
-				<el-table-column property="wtId" align="center" label="风机" />
+				<el-table-column property="windturbine" align="center" label="风机" />
 				<el-table-column
-					property="speed"
+					property="pc5ratio"
 					sortable
 					align="center"
 					label="3~5m"
 				/>
 				<el-table-column
-					property="power"
+					property="pc10ratio"
 					sortable
 					align="center"
 					label="5~10m"
 				/>
 				<el-table-column
-					property="rr"
+					property="pc12ratio"
 					sortable
 					align="center"
 					label="10~12m"
 				/>
 				<el-table-column
-					property="filter"
+					property="pc25ratio"
 					sortable
 					align="center"
 					label="12~25m"
 				/>
 				<el-table-column
-					property="filter"
+					property="pcratio"
 					sortable
 					align="center"
 					label="3~25m"

+ 11 - 9
src/pages/dataAnalysis/rateAnalysis/components/chart.vue

@@ -1,7 +1,7 @@
 <script setup>
 import util from "@tools/util";
 import chartTheme from './../chartTheme.json'
-import { ref, toRaw, computed, onMounted, watch } from 'vue';
+import { ref, toRaw, computed, onMounted, watch, nextTick } from 'vue';
 import * as echarts from 'echarts'
 const chartId = 'chart-' + util.newGUID(); //chartId
 const chartIns = ref(null)  //chart 实例
@@ -48,7 +48,7 @@ const option = computed({
 				text: props.title || '',
 				subtext: props.subtext || '',
 				top: 10,
-				left: 30,
+				left: props.isDiaAlone? '22%' : '5%',
 			},
 			angleAxis: props.xAxis || {},
 			radiusAxis: {},
@@ -58,7 +58,7 @@ const option = computed({
 			},
 			tooltip: {
 				formatter: (params) => {
-					return params.componentSubType==='line'? `${params.seriesName}频次:${params.value}` : `${params.seriesName}m<br/>${params.value>1? '频次:'+ params.value: ''}`
+					return params.componentSubType==='line'? `${params.marker}${params.seriesName}频次:${params.value}` : `${params.marker}${params.seriesName}m<br/>${params.value>1? '频次:'+ params.value: ''}`
 				},
 				confine: true
 			},
@@ -87,12 +87,14 @@ watch(() => option, (newVal, oldVal) => {
 }, { deep: true })
 
 onMounted(() => {
-	echarts.registerTheme('chartTheme', chartTheme)
-	const echartIns =	echarts.init(document.getElementById(chartId),'chartTheme') 
-	chartIns.value = echartIns
-	echartIns.setOption(option.value)
-	window.addEventListener('resize', () => {
-		echartIns.resize()
+	nextTick(() => {
+		echarts.registerTheme('chartTheme', chartTheme)
+		const echartIns =	echarts.init(document.getElementById(chartId),'chartTheme') 
+		chartIns.value = echartIns
+		echartIns.setOption(option.value)
+		window.addEventListener('resize', () => {
+			echartIns.resize()
+		})
 	})
 })
 </script>

+ 10 - 8
src/pages/dataAnalysis/rateAnalysis/components/lineChart.vue

@@ -66,7 +66,7 @@ const option = computed({
 				text: props.title || '',
 				subtext: props.subtext || '',
 				top: 6,
-				left: 30,
+				left: '5%',
 			},
 			xAxis: props.xAxis || {},
 			yAxis: props.yAxis || {},
@@ -162,13 +162,15 @@ const funBrushChange = (flag) => {
 watch(() => props.brush, (newVal, oldVal) => funBrushChange(newVal))
 
 onMounted(() => {
-	echarts.registerTheme('chartTheme', chartTheme)
-	const echartIns =	echarts.init(document.getElementById(chartId),'chartTheme') 
-	chartIns.value = echartIns
-	echartIns.setOption(option.value)
-	funBrushChange(props.brush)
-	window.addEventListener('resize', () => {
-		echartIns.resize()
+	nextTick(() => {
+		echarts.registerTheme('chartTheme', chartTheme)
+		const echartIns =	echarts.init(document.getElementById(chartId),'chartTheme') 
+		chartIns.value = echartIns
+		echartIns.setOption(option.value)
+		funBrushChange(props.brush)
+		window.addEventListener('resize', () => {
+			echartIns.resize()
+		})
 	})
 })
 </script>

+ 9 - 7
src/pages/dataAnalysis/rateAnalysis/components/scatterSingleChart.vue

@@ -63,7 +63,7 @@ const option = computed({
 				text: props.title || '',
 				subtext: props.subtext || '',
 				top: 6,
-				left: 30,
+				left: '5%',
 			},
 			grid: {
 				top: 40,
@@ -119,12 +119,14 @@ watch(() => option, (newVal, oldVal) => {
 }, { deep: true })
 
 onMounted(() => {
-	echarts.registerTheme('chartTheme', chartTheme)
-	const echartIns = echarts.init(document.getElementById(chartId), 'chartTheme')
-	chartIns.value = echartIns
-	echartIns.setOption(option.value)
-	window.addEventListener('resize', () => {
-		echartIns.resize()
+	nextTick(() => {
+		echarts.registerTheme('chartTheme', chartTheme)
+		const echartIns = echarts.init(document.getElementById(chartId), 'chartTheme')
+		chartIns.value = echartIns
+		echartIns.setOption(option.value)
+		window.addEventListener('resize', () => {
+			echartIns.resize()
+		})
 	})
 })
 </script>

+ 1 - 2
src/pages/dataAnalysis/rateAnalysis/index.vue

@@ -437,7 +437,6 @@ const funActCop = (obj, type) => {
 	obj.isBrush = type === 'lineChartCop' ? true :false
 	obj.id = chartId
 	chartId ++
-	obj.isDiaAlone = true
 	dialog.value = true
 	nextTick(() => {
 		actCopList.value = [obj]
@@ -675,7 +674,7 @@ onActivated(() => {
 			<div class="flex flex-wrap justify-center items-center h-[750px] overflow-y-auto overflow-x-hidden">
 				<component :is="item.actCop" :width="actCopList.length > 1 ? '50%' : '100%'" height="600px" v-for="item in actCopList"
 					:key="item.id" :xAxis="item.xAxis" :subtext="item.subtext" :title="item.title"
-					:series="item.series" :isDiaAlone="item.isDiaAlone || false" :yAxis="item.yAxis" :dataset="item.dataset" :brush="item.isBrush" @getSelected="funChartSelect"></component>
+					:series="item.series" :isDiaAlone="(actCopList.length === 1)" :yAxis="item.yAxis" :dataset="item.dataset" :brush="item.isBrush" @getSelected="funChartSelect"></component>
 			</div>
 		</el-dialog>
 		<div class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[10px] pb-[10px]">