二级系统联合寻找数据
This commit is contained in:
127
klp-ui/src/views/da/oee/components/OeeLossPareto.vue
Normal file
127
klp-ui/src/views/da/oee/components/OeeLossPareto.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div class="oee-chart" ref="chartRef"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
name: 'OeeLossPareto',
|
||||
props: {
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chart: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initChart()
|
||||
window.addEventListener('resize', this.handleResize)
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.handleResize)
|
||||
if (this.chart) {
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
data: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.render()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toFixed3(val) {
|
||||
const n = Number(val)
|
||||
return Number.isFinite(n) ? n.toFixed(3) : '-'
|
||||
},
|
||||
initChart() {
|
||||
if (!this.$refs.chartRef) return
|
||||
this.chart = echarts.init(this.$refs.chartRef)
|
||||
},
|
||||
render() {
|
||||
if (!this.chart) this.initChart()
|
||||
if (!this.chart) return
|
||||
const list = Array.isArray(this.data) ? this.data : []
|
||||
const names = list.map(d => d.lossCategoryName)
|
||||
const mins = list.map(d => Number(d.lossTimeMin || 0))
|
||||
const percents = list.map(d => Number(d.lossTimeRate || 0))
|
||||
const cum = []
|
||||
percents.reduce((acc, cur) => {
|
||||
const v = acc + cur
|
||||
cum.push(Math.min(100, v))
|
||||
return v
|
||||
}, 0)
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: params => {
|
||||
const title = (params && params[0] && params[0].axisValue) || ''
|
||||
const lines = (params || []).map(p => {
|
||||
const suffix = p.seriesName === '累计占比' ? ' %' : ' min'
|
||||
return `${p.marker}${p.seriesName}:${this.toFixed3(p.value)}${suffix}`
|
||||
})
|
||||
return [title, ...lines].join('<br/>')
|
||||
}
|
||||
},
|
||||
grid: { left: 40, right: 60, top: 30, bottom: 80 },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: names,
|
||||
axisLabel: { interval: 0, rotate: 40, fontSize: 10 }
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '损失时间 (min)',
|
||||
axisLabel: { formatter: v => this.toFixed3(v) }
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '累计占比 (%)',
|
||||
min: 0,
|
||||
max: 100,
|
||||
position: 'right',
|
||||
axisLabel: { formatter: v => this.toFixed3(v) }
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '损失时间',
|
||||
type: 'bar',
|
||||
data: mins,
|
||||
itemStyle: { color: '#F56C6C' }
|
||||
},
|
||||
{
|
||||
name: '累计占比',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
data: cum,
|
||||
smooth: true,
|
||||
itemStyle: { color: '#409EFF' }
|
||||
}
|
||||
]
|
||||
}
|
||||
this.chart.setOption(option)
|
||||
},
|
||||
handleResize() {
|
||||
this.chart && this.chart.resize()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.oee-chart {
|
||||
width: 100%;
|
||||
height: 260px;
|
||||
}
|
||||
</style>
|
||||
106
klp-ui/src/views/da/oee/components/OeeStoppageTop.vue
Normal file
106
klp-ui/src/views/da/oee/components/OeeStoppageTop.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div class="oee-chart" ref="chartRef"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
name: 'OeeStoppageTop',
|
||||
props: {
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
topN: {
|
||||
type: Number,
|
||||
default: 10
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chart: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initChart()
|
||||
window.addEventListener('resize', this.handleResize)
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.handleResize)
|
||||
if (this.chart) {
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
data: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.render()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toFixed3(val) {
|
||||
const n = Number(val)
|
||||
return Number.isFinite(n) ? n.toFixed(3) : '-'
|
||||
},
|
||||
initChart() {
|
||||
if (!this.$refs.chartRef) return
|
||||
this.chart = echarts.init(this.$refs.chartRef)
|
||||
},
|
||||
render() {
|
||||
if (!this.chart) this.initChart()
|
||||
if (!this.chart) return
|
||||
const list = Array.isArray(this.data) ? this.data.slice() : []
|
||||
list.sort((a, b) => (b.duration || 0) - (a.duration || 0))
|
||||
const top = list.slice(0, this.topN)
|
||||
const names = top.map((d, idx) => `${idx + 1}. ${d.stopType || '未知'}`)
|
||||
const mins = top.map(d => Number(((d.duration || 0) / 60).toFixed(3)))
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
formatter: params => {
|
||||
const p = params && params[0]
|
||||
if (!p) return ''
|
||||
return `${p.name}<br/>${p.marker}${p.seriesName}:${this.toFixed3(p.value)} min`
|
||||
}
|
||||
},
|
||||
grid: { left: 140, right: 20, top: 20, bottom: 20 },
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
name: '停机时间 (min)',
|
||||
axisLabel: { formatter: v => this.toFixed3(v) }
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: names,
|
||||
axisLabel: { fontSize: 11 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '停机时间 (min)',
|
||||
type: 'bar',
|
||||
data: mins,
|
||||
itemStyle: { color: '#67C23A' }
|
||||
}
|
||||
]
|
||||
}
|
||||
this.chart.setOption(option)
|
||||
},
|
||||
handleResize() {
|
||||
this.chart && this.chart.resize()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.oee-chart {
|
||||
width: 100%;
|
||||
height: 260px;
|
||||
}
|
||||
</style>
|
||||
97
klp-ui/src/views/da/oee/components/OeeTrendChart.vue
Normal file
97
klp-ui/src/views/da/oee/components/OeeTrendChart.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="oee-chart" ref="chartRef"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
export default {
|
||||
name: 'OeeTrendChart',
|
||||
props: {
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chart: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initChart()
|
||||
window.addEventListener('resize', this.handleResize)
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.handleResize)
|
||||
if (this.chart) {
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
data: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler() {
|
||||
this.render()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toFixed3(val) {
|
||||
const n = Number(val)
|
||||
return Number.isFinite(n) ? n.toFixed(3) : '-'
|
||||
},
|
||||
initChart() {
|
||||
if (!this.$refs.chartRef) return
|
||||
this.chart = echarts.init(this.$refs.chartRef)
|
||||
},
|
||||
render() {
|
||||
if (!this.chart) this.initChart()
|
||||
if (!this.chart) return
|
||||
const list = Array.isArray(this.data) ? this.data : []
|
||||
const x = list.map(d => d.statDate)
|
||||
const oee = list.map(d => Number(d.oee || 0))
|
||||
const a = list.map(d => Number(d.availability || 0))
|
||||
const p = list.map(d => Number(d.performanceTon || 0))
|
||||
const q = list.map(d => Number(d.quality || 0))
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: params => {
|
||||
const title = (params && params[0] && params[0].axisValue) || ''
|
||||
const lines = (params || []).map(p0 => `${p0.marker}${p0.seriesName}:${this.toFixed3(p0.value)} %`)
|
||||
return [title, ...lines].join('<br/>')
|
||||
}
|
||||
},
|
||||
legend: { top: 0, left: 'center' },
|
||||
grid: { left: 40, right: 20, top: 30, bottom: 40 },
|
||||
xAxis: { type: 'category', data: x },
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: '百分比 (%)',
|
||||
axisLabel: { formatter: v => this.toFixed3(v) }
|
||||
},
|
||||
series: [
|
||||
{ name: 'OEE', type: 'line', data: oee, smooth: true },
|
||||
{ name: 'A', type: 'line', data: a, smooth: true },
|
||||
{ name: 'P_ton', type: 'line', data: p, smooth: true },
|
||||
{ name: 'Q', type: 'line', data: q, smooth: true }
|
||||
]
|
||||
}
|
||||
this.chart.setOption(option)
|
||||
},
|
||||
handleResize() {
|
||||
this.chart && this.chart.resize()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.oee-chart {
|
||||
width: 100%;
|
||||
height: 260px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user