spring
13 小时以前 519211ac232866afe6b081ae4a97916ad5f1d7d2
src/views/reportAnalysis/dataDashboard/components/basic/right-top.vue
@@ -25,7 +25,7 @@
import Echarts from '@/components/Echarts/echarts.vue'
import PanelHeader from '../PanelHeader.vue'
import DateTypeSwitch from '../DateTypeSwitch.vue'
import { statisticsReceivablePayable } from '@/api/viewIndex.js'
import { supplierPurchaseRanking } from '@/api/viewIndex.js'
const chartStyle = {
  width: '100%',
@@ -151,12 +151,21 @@
      inverse: false,
      data: xdataName.value,
      axisLabel: {
        formatter: (params) => {
          return `{a|${params}}`
        formatter: (value) => {
          if (!value) return ''
          const maxLen = 6 // 每行最多字符数,可按需调整
          if (value.length <= maxLen) return `{a|${value}}`
          const lines = []
          for (let i = 0; i < value.length; i += maxLen) {
            lines.push(value.slice(i, i + maxLen))
          }
          // 多行文本,每行都套同一个 rich 样式
          return lines.map((line) => `{a|${line}}`).join('\n')
        },
        rich: {
          a: {
            width: 160,
            width: 120,
            fontSize: 14,
            color: '#fff',
            padding: [5, 4, 5, 0],
@@ -242,6 +251,7 @@
      z: 6,
      type: 'bar',
      barWidth: 25,
      tooltip: { show: false },
      itemStyle: {
        color: 'rgba(255,255,255,.1)',
        barBorderRadius: [0, 20, 20, 0],
@@ -252,6 +262,7 @@
      type: 'bar',
      barWidth: 25,
      barGap: '-100%',
      tooltip: { show: false },
      itemStyle: {
        color: {
          type: 'linear',
@@ -282,16 +293,15 @@
  ]
})
// 应付应收统计
const statisticsReceivable = () => {
  statisticsReceivablePayable({ type: radio1.value })
// 供应商采购排名
const fetchSupplierRanking = () => {
  supplierPurchaseRanking({ type: radio1.value })
    .then((res) => {
      // 假设 API 返回的数据格式为数组,包含 NAME 和 NUM 字段
      // 如果返回格式不同,需要根据实际 API 调整
      if (res.data && Array.isArray(res.data)) {
        dataArr.value = res.data
      } else if (res.data && res.data.list) {
        dataArr.value = res.data.list
      if (res.code === 200 && Array.isArray(res.data)) {
        dataArr.value = res.data.map(item => ({
          NAME: item.supplierName,
          NUM: item.totalAmount
        }))
      } else {
        // 如果没有数据,使用模拟数据
        dataArr.value = [
@@ -318,11 +328,11 @@
// 处理日期类型切换
const handleDateTypeChange = (value) => {
  statisticsReceivable()
  fetchSupplierRanking()
}
onMounted(() => {
  statisticsReceivable()
  fetchSupplierRanking()
})
</script>