|
|
|
@ -19,6 +19,7 @@
|
|
|
|
import { onMounted } from 'vue'
|
|
|
|
import { onMounted } from 'vue'
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
import { useChart, colors, style } from '../utils'
|
|
|
|
import { useChart, colors, style } from '../utils'
|
|
|
|
|
|
|
|
import { PlanApi } from '@/api/mes/plan'
|
|
|
|
|
|
|
|
|
|
|
|
const { init } = useChart('chart-quality')
|
|
|
|
const { init } = useChart('chart-quality')
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,7 +32,54 @@ for (let i = 6; i >= 0; i--) {
|
|
|
|
|
|
|
|
|
|
|
|
const passRate = [98.5, 99.2, 97.8, 98.9, 99.0, 98.2, 99.5]
|
|
|
|
const passRate = [98.5, 99.2, 97.8, 98.9, 99.0, 98.2, 99.5]
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
type QualityPoint = {
|
|
|
|
|
|
|
|
label: string
|
|
|
|
|
|
|
|
rate: number
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const normalizeQualityData = (raw: any): QualityPoint[] => {
|
|
|
|
|
|
|
|
if (!raw) return []
|
|
|
|
|
|
|
|
const source = raw && typeof raw === 'object' && 'data' in raw ? raw.data : raw
|
|
|
|
|
|
|
|
const rows: QualityPoint[] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(source)) {
|
|
|
|
|
|
|
|
source.forEach((row: any) => {
|
|
|
|
|
|
|
|
const rawDate = row?.day ?? row?.date ?? row?.statDate ?? row?.createDate ?? ''
|
|
|
|
|
|
|
|
const rawLabel = typeof rawDate === 'string' ? rawDate : String(rawDate || '')
|
|
|
|
|
|
|
|
const label = rawLabel.length >= 10 ? rawLabel.slice(5, 10).replace('-', '/') : rawLabel
|
|
|
|
|
|
|
|
const rawRate = row?.rate ?? row?.passRate ?? row?.qualifiedRate ?? row?.value ?? 0
|
|
|
|
|
|
|
|
const n = Number(rawRate)
|
|
|
|
|
|
|
|
const rate = Number.isNaN(n) ? 0 : n
|
|
|
|
|
|
|
|
rows.push({ label, rate })
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} else if (source && typeof source === 'object') {
|
|
|
|
|
|
|
|
const entries = Object.entries(source).sort(([a], [b]) => a.localeCompare(b))
|
|
|
|
|
|
|
|
entries.forEach(([key, value]) => {
|
|
|
|
|
|
|
|
const rawLabel = String(key || '')
|
|
|
|
|
|
|
|
const label = rawLabel.length >= 10 ? rawLabel.slice(5, 10).replace('-', '/') : rawLabel
|
|
|
|
|
|
|
|
const n = Number(value)
|
|
|
|
|
|
|
|
const rate = Number.isNaN(n) ? 0 : n
|
|
|
|
|
|
|
|
rows.push({ label, rate })
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rows.filter((item) => item.label)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
|
|
let xAxisData = last7Days.slice()
|
|
|
|
|
|
|
|
let seriesData = passRate.slice()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const data = await PlanApi.getLastDaysRate()
|
|
|
|
|
|
|
|
const list = normalizeQualityData(data)
|
|
|
|
|
|
|
|
if (list.length > 0) {
|
|
|
|
|
|
|
|
xAxisData = list.map((item) => item.label)
|
|
|
|
|
|
|
|
seriesData = list.map((item) => item.rate)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const chart = init()
|
|
|
|
const chart = init()
|
|
|
|
if (!chart) return
|
|
|
|
if (!chart) return
|
|
|
|
|
|
|
|
|
|
|
|
@ -39,8 +87,8 @@ onMounted(() => {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
tooltip: { trigger: 'axis' },
|
|
|
|
tooltip: { trigger: 'axis' },
|
|
|
|
grid: { top: '18%', left: '6%', right: '6%', bottom: '10%', containLabel: true },
|
|
|
|
grid: { top: '18%', left: '6%', right: '6%', bottom: '10%', containLabel: true },
|
|
|
|
xAxis: { type: 'category', data: last7Days, axisLine: style.axisLine, axisLabel: style.axisLabel },
|
|
|
|
xAxis: { type: 'category', data: xAxisData, axisLine: style.axisLine, axisLabel: style.axisLabel },
|
|
|
|
yAxis: { type: 'value', min: 96, max: 100, axisLine: { show: false }, axisLabel: style.axisLabel, splitLine: style.splitLine },
|
|
|
|
yAxis: { type: 'value', min: 0, max: 100, axisLine: { show: false }, axisLabel: style.axisLabel, splitLine: style.splitLine },
|
|
|
|
series: [{
|
|
|
|
series: [{
|
|
|
|
name: '合格率',
|
|
|
|
name: '合格率',
|
|
|
|
type: 'bar',
|
|
|
|
type: 'bar',
|
|
|
|
@ -52,7 +100,7 @@ onMounted(() => {
|
|
|
|
{ offset: 1, color: 'rgba(139,92,246,0.10)' }
|
|
|
|
{ offset: 1, color: 'rgba(139,92,246,0.10)' }
|
|
|
|
])
|
|
|
|
])
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data: passRate,
|
|
|
|
data: seriesData,
|
|
|
|
markLine: {
|
|
|
|
markLine: {
|
|
|
|
symbol: ['none', 'none'],
|
|
|
|
symbol: ['none', 'none'],
|
|
|
|
label: { show: true, color: '#fff', fontSize: 12, formatter: '平均 {c}%' },
|
|
|
|
label: { show: true, color: '#fff', fontSize: 12, formatter: '平均 {c}%' },
|
|
|
|
|