Files
app-govern/pages/device/APF/comp/xieBo.vue

210 lines
7.1 KiB
Vue
Raw Normal View History

2023-02-06 13:34:15 +08:00
<template>
<view>
2023-09-14 15:45:55 +08:00
<uni-data-checkbox v-model="parity" :localdata="parityOption" @change="initEcharts"></uni-data-checkbox>
<uni-data-checkbox v-model="dataRadio" :localdata="dataOptions" @change="initEcharts"></uni-data-checkbox>
2023-02-06 13:34:15 +08:00
<view class="charts-box">
2023-08-23 16:22:08 +08:00
<qiun-data-charts type="column" :ontouch='true' :opts="opts" :chartData="chartData"/>
2023-02-06 13:34:15 +08:00
</view>
</view>
</template>
<script>
export default {
2023-08-18 14:41:53 +08:00
props: {
basicData: {
type: Array,
2023-08-23 16:22:08 +08:00
default: () => [],
},
2023-08-18 14:41:53 +08:00
},
data() {
2023-02-06 13:34:15 +08:00
return {
2023-09-14 15:45:55 +08:00
parityOption: [
{
text: '奇次',
value: 2,
},
{
text: '偶次',
value: 1,
}
],
parity: 2,
dataOptions: [],
dataRadio: 0,
2023-08-18 14:41:53 +08:00
renderData: {
2023-09-14 15:45:55 +08:00
电网侧: {
Apf_HarmI: {},
Apf_HarmUR: {},
},
负载侧: {
Apf_HarmI: {},
Apf_HarmUR: {},
},
2023-08-18 14:41:53 +08:00
},
2023-02-06 13:34:15 +08:00
chartData: {},
//您可以通过修改 config-ucharts.js 文件中下标为 ['column'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
opts: {
enableScroll: true,
2023-08-23 16:22:08 +08:00
color: [
'#1890FF',
'#91CB74',
'#FAC858',
'#EE6666',
'#73C0DE',
'#3CA272',
'#FC8452',
'#9A60B4',
'#ea7ccc',
],
padding: [20, 10, 0, 0],
2023-02-06 13:34:15 +08:00
legend: {},
xAxis: {
disableGrid: true,
itemCount: 8,
2023-03-22 14:09:51 +08:00
// scrollShow: true,
2023-08-23 16:22:08 +08:00
data: [
{
min: 0,
},
],
2023-02-06 13:34:15 +08:00
},
yAxis: {
data: [
{
2023-08-23 16:22:08 +08:00
min: 0,
tofix: 4,
},
],
2023-02-06 13:34:15 +08:00
},
extra: {
column: {
2023-08-23 16:22:08 +08:00
width: 10,
categoryGap: 1,
},
2023-02-06 13:34:15 +08:00
},
2023-08-23 16:22:08 +08:00
},
}
2023-02-06 13:34:15 +08:00
},
2023-08-18 14:41:53 +08:00
watch: {
basicData: {
handler: function (newVal, oldVal) {
2023-09-13 16:40:03 +08:00
console.log(this.basicData)
2023-08-18 14:41:53 +08:00
let basicData = JSON.parse(JSON.stringify(this.basicData))
2023-09-14 15:45:55 +08:00
this.dataRadio = 0
this.renderData = {
电网侧: {
Apf_HarmI: {},
Apf_HarmUR: {},
},
负载侧: {
Apf_HarmI: {},
Apf_HarmUR: {},
},
}
2023-08-18 14:41:53 +08:00
let arr = [
{
name: '电网侧',
2023-09-13 16:40:03 +08:00
key: 'Apf_HarmI_Sys',
2023-08-18 14:41:53 +08:00
},
2023-09-14 15:45:55 +08:00
{
name: '电网侧',
key: 'Apf_HarmUR_Sys',
},
2023-08-18 14:41:53 +08:00
{
name: '负载侧',
2023-09-13 16:40:03 +08:00
key: 'Apf_HarmI_Load',
2023-08-18 14:41:53 +08:00
},
2023-09-14 15:45:55 +08:00
{
name: '负载侧',
key: 'Apf_HarmUR_Load',
},
2023-08-18 14:41:53 +08:00
]
basicData.forEach((item) => {
2023-09-14 15:45:55 +08:00
let have = arr.find((item2) => {
2023-09-13 16:40:03 +08:00
return item.statisticalName.indexOf(item2.key) > -1
2023-08-18 14:41:53 +08:00
})
2023-09-14 15:45:55 +08:00
if (!have) return
let name1 = have['name']
let name2 = have.key.split('_')[0] + '_' + have.key.split('_')[1]
if (this.renderData[name1][name2][item.phase]) {
this.renderData[name1][name2][item.phase][item.statisticalName] =
item.statisticalData || 0
} else {
this.renderData[name1][name2][item.phase] = {
[item.statisticalName]: item.statisticalData || 0,
2023-08-18 14:41:53 +08:00
}
}
})
console.log(this.renderData)
2023-09-14 15:45:55 +08:00
let dataOptions = []
let type = [
{
name: 'Apf_HarmI',
key: 'Apf_HarmI',
},
{
name: 'Apf_HarmUR',
key: 'Apf_HarmUR',
2023-08-18 14:41:53 +08:00
}
2023-09-14 15:45:55 +08:00
]
Object.keys(this.renderData['电网侧']['Apf_HarmI']).forEach((item, index) => {
type.forEach(item2 => {
dataOptions.push({
text: item + '_' + item2.name,
pointer: item2.key + '_' + item,
value: dataOptions.length,
})
})
2023-08-18 14:41:53 +08:00
})
2023-09-14 15:45:55 +08:00
this.dataOptions = dataOptions
console.log(dataOptions)
this.initEcharts()
2023-08-18 14:41:53 +08:00
},
deep: true,
immediate: true,
2023-02-06 13:34:15 +08:00
},
2023-08-23 16:22:08 +08:00
},
2023-09-14 15:45:55 +08:00
methods: {
initEcharts() {
let obj = JSON.parse(
JSON.stringify(this.renderData['电网侧']['Apf_HarmI'][Object.keys(this.renderData['电网侧']['Apf_HarmI'])[0]]),
)
let key = this.dataOptions[this.dataRadio].pointer.split('_')
console.log(key)
let name1 = key[0] + '_' + key[1]
let name2 = key[2]
this.chartData = {
categories: Object.keys(obj).map((item) => {
// Apf_HarmI_Sys_36(A) 匹配36
return Number(item.match(/\d+/)[0])
}).filter((item) => {
return item % 2 === this.parity - 1
}),
series: [
{
name: '电网侧',
data: Object.values(this.renderData['电网侧'][name1][name2]).filter((item, index) => {
return index % 2 === this.parity - 1
}),
},
{
name: '负载侧',
data: Object.values(this.renderData['负载侧'][name1][name2]).filter((item, index) => {
return index % 2 === this.parity - 1
}),
},
],
}
}
}
2023-08-18 14:41:53 +08:00
}
2023-02-06 13:34:15 +08:00
</script>
<style lang="scss">
.charts-box {
margin-top: 20rpx;
2023-08-23 16:22:08 +08:00
height: 800rpx;
2023-02-06 13:34:15 +08:00
}
2023-08-23 16:22:08 +08:00
</style>