gaoluyang
19 小时以前 e0cb2008ffb01348b54a7370180a100f3c975877
src/views/reportAnalysis/productionAnalysis/components/right-bottom.vue
@@ -28,27 +28,27 @@
import DateTypeSwitch from './DateTypeSwitch.vue'
import Echarts from '@/components/Echarts/echarts.vue'
const dateType = ref(1) // 1=周 2=月 3=季度
const dateType = ref(1)
const chartStyle = {
  width: '100%',
  height: '140%',
}
const grid = { left: '10%', right: '4%', bottom: '3%', top: '10%', containLabel: true }
const grid = { left: '3%', right: '4%', bottom: '3%', top: '10%', containLabel: true }
const barLegend = {
  show: true,
  textStyle: { color: '#B8C8E0' },
  data: ['生产核算'],
  data: ['完成数量', '工资金额', '合格率'],
}
// 柱状图:生产核算
const chartSeries = ref([
  {
    name: '生产核算',
    name: '完成数量',
    type: 'bar',
    barWidth: 30,
    barWidth: 20,
    barGap: '40%',
    emphasis: { focus: 'series' },
    itemStyle: {
      color: {
@@ -65,7 +65,63 @@
    },
    data: [],
  },
  {
    name: '工资金额',
    type: 'bar',
    barGap: '40%',
    barWidth: 20,
    emphasis: { focus: 'series' },
    itemStyle: {
      color: {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          { offset: 1, color: 'rgba(83, 126, 245, 0.19)' },
          { offset: 0, color: 'rgba(144, 97, 248, 1)' },
        ],
      },
    },
    data: [],
  },
  {
    name: '合格率',
    type: 'line',
    yAxisIndex: 1,
    showSymbol: true,
    symbol: 'circle',
    symbolSize: 8,
    lineStyle: { color: 'rgba(90, 216, 166, 1)', width: 2 },
    itemStyle: { color: 'rgba(90, 216, 166, 1)' },
    data: [],
    emphasis: { focus: 'series' },
  },
])
const xAxis1 = ref([
  { type: 'category', axisTick: { show: false }, axisLabel: { color: '#B8C8E0' }, data: [] },
])
const yAxis1 = [
  {
    type: 'value',
    name: '数量/金额',
    axisLabel: { color: '#B8C8E0' },
    nameTextStyle: { color: '#B8C8E0' },
    // splitLine: { lineStyle: { color: 'rgba(184, 200, 224, 0.2)' } },
  },
  {
    type: 'value',
    name: '合格率(%)',
    min: 0,
    max: 100,
    axisLabel: { color: '#B8C8E0', formatter: '{value}%' },
    nameTextStyle: { color: '#B8C8E0' },
    splitLine: { lineStyle: { color: 'rgba(184, 200, 224, 0.2)' } },
  },
]
const tooltip = {
  trigger: 'axis',
@@ -73,33 +129,31 @@
  formatter(params) {
    let result = params[0].axisValueLabel + '<br/>'
    params.forEach((item) => {
      result += `<div>${item.marker} ${item.seriesName}: ${item.value} 元</div>`
      const unit = item.seriesName === '合格率' ? '%' : (item.seriesName === '工资金额' ? ' 元' : ' 个')
      result += `<div>${item.marker} ${item.seriesName}: ${item.value}${unit}</div>`
    })
    return result
  },
}
const xAxis1 = ref([
  { type: 'category', axisTick: { show: false }, axisLabel: { color: '#B8C8E0' }, data: [] },
])
const yAxis1 = [
  { type: 'value', name: '单位: 元', axisLabel: { color: '#B8C8E0' }, nameTextStyle: { color: '#B8C8E0' }, splitLine: { lineStyle: { color: 'rgba(184, 200, 224, 0.2)' } } },
]
const handleDateTypeChange = () => {
  fetchData()
}
const fetchData = () => {
  productionAccountingAnalysis({ dateType: dateType.value })
  productionAccountingAnalysis({ type: dateType.value })
    .then((res) => {
      if (res.code !== 200 || !Array.isArray(res.data)) return
      const items = res.data
      xAxis1.value[0].data = items.map((d) => d.name)
      chartSeries.value[0].data = items.map((d) => parseFloat(d.value) || 0)
      if (res.code === 200 && Array.isArray(res.data)) {
        const items = res.data
        xAxis1.value[0].data = items.map(item => item.dateStr)
        chartSeries.value[0].data = items.map(item => Number(item.numberOfCompleted) || 0)
        chartSeries.value[1].data = items.map(item => Number(item.amount) || 0)
        chartSeries.value[2].data = items.map(item => Number(item.passRate) || 0)
      }
    })
    .catch((err) => {
      console.error('获取生产核算分析失败:', err)
      console.error('数据加载失败', err)
    })
}
@@ -128,5 +182,6 @@
  padding: 18px;
  width: 100%;
  height: 449px;
  box-sizing: border-box;
}
</style>
</style>